![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前端开发
文章平均质量分 52
liuzheng068
成长比成功更重要。
展开
-
react hooks
1.useState—数据存储与更新1.语法const [state, setState] = useState(initialState)2.语法说明state为变量setState为修改state值的方法//引入 React 中的 useState Hook。它让我们在函数组件中存储内部 state。import React, { useState } from 'react';function Example() { // 声明一个叫 “count” 的 state 变量,原创 2021-12-01 10:46:19 · 818 阅读 · 0 评论 -
组件三大属性
组件三大属性state理解state 是组件对象最重要的属性,值是一个对象(可以包含多组 key-value)组件被称为"状态机",通过更新组件的 state 来更新对应的页面(重新渲染组件)强烈注意组件render()中的 this 是组件实例对象组件中自定义方法中的this为 undefined,如何解决?强制绑定 this,通过函数对象的bind()箭头函数状态数据不能直接修改,可通过setState()进行修改// 错误this.state.title = 'R原创 2021-11-08 22:53:56 · 488 阅读 · 0 评论 -
react-函数组件与类组件
函数组件与 class 组件函数组件//创建函数式组件function Mycomponent() { console.log(this); //此处的 this 为 undefined,因为Babel编译后开启了严格模式 return <div>我是用 函数组件 创建的组件,适用于简单场景</div>;}//渲染组件ReactDOM.render(<Mycomponent />, document.getElementById("root"));/原创 2021-11-08 22:36:27 · 535 阅读 · 0 评论 -
Vue中Object.defineProperty的使用
<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-原创 2021-08-23 20:27:16 · 331 阅读 · 0 评论