赞
踩
此为typescript版本
- import { useState } from 'react';
-
- const TestCom: React.FC = (props) => {
- const [loading, setLoading] = useState<boolean>(false);
- // setLoading就是改变loading值的方法
-
- return (
- <div>
- <button onClick={()=>{setLoading(true)}}>点击改变loading值</button>
- </div>
- )
- }
- import React from 'react'
-
- class TestCom extends React.Component {
-
- state = {
- loading: false
- }
-
- // 修改状态数据的值
- handlerChange=()=>{
- this.setState({
- loading: true
- })
- }
-
- // 模版
- render() {
- <div>
- <p>{this.state.loading}</p>
- <button onClick={this.handlerChange}>handlerChange</button>
- </div>
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。