上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 37 下一页
摘要: const newList = list.slice(); 不要用等号赋值 (一些引用类型直接复制不会引起页面的重新渲染,所以尽可能使用数组方法完成业务需求) 原因: 对象数组是引用方式 , 对于 react 来说它的值都是地址 (涉及到 tree diff),因为没有被重新赋值 (地址没有改变), 阅读全文
posted @ 2022-06-23 14:15 SimoonJia 阅读(49) 评论(0) 推荐(0)
摘要: 1、setState() 2、props发生变化 3、forceUpdate() 阅读全文
posted @ 2022-06-23 14:14 SimoonJia 阅读(1217) 评论(0) 推荐(0)
摘要: <Input style={{ marginTop: '10px', marginRight: '10px', width: '200px' }} onChange={changeInputValue} /> const changeInputValue = (e) => { //e:改变的值都可以 阅读全文
posted @ 2022-06-23 10:39 SimoonJia 阅读(740) 评论(0) 推荐(0)
摘要: 报错原因 在新版本的npm中,默认情况下,npm install遇到冲突的peerDependencies时将失败。 解决办法 使用--force或--legacy-peer-deps可解决这种情况。 --force 会无视冲突,并强制获取远端npm库资源,当有资源冲突时覆盖掉原先的版本。--leg 阅读全文
posted @ 2022-06-22 17:38 SimoonJia 阅读(1168) 评论(0) 推荐(0)
摘要: 例如 npm i nrm -g 报 Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nrm' 在命令前加上sudo即可 如: sudo npm i nrm -g 阅读全文
posted @ 2022-06-22 16:57 SimoonJia 阅读(98) 评论(0) 推荐(0)
摘要: TodoList.js componentDidMount(){ store.subscribe(this.storeChange) //订阅 axios.get('https://........').then((res)=>{ const data=res.data const action=g 阅读全文
posted @ 2022-06-21 23:52 SimoonJia 阅读(106) 评论(0) 推荐(0)
摘要: 删除this,用props作为参数代替this.props 性能比类组件性能优秀 JSX语法必须引入React TodoListUI.js import React from 'react' import {Input,Button,List} from 'antd' const TodoListU 阅读全文
posted @ 2022-06-21 23:21 SimoonJia 阅读(100) 评论(0) 推荐(0)
摘要: 将组件中所用数据和方法通过props传给子UI组件,子UI组件调用这些数据和方法完成页面渲染(业务逻辑层的构造函数不变) TodtListUI.js import React, { Component } from 'react' import {Input,Button,List} from 'a 阅读全文
posted @ 2022-06-21 02:30 SimoonJia 阅读(151) 评论(0) 推荐(0)
摘要: export const getListAction=(data)=>({ type:GET_LIST, data }) const action=getListAction(data) 调用该方法,取到的是括号内部的值 所以该写法可看作()=>{return{}} 首先这里用的时ES6的箭头函数 阅读全文
posted @ 2022-06-21 02:22 SimoonJia 阅读(408) 评论(0) 推荐(0)
摘要: 报错的意思应该是因为必须在组件挂载后订阅 componentDidMount(){ // store.subscribe(this.storeChange) //订阅 } 阅读全文
posted @ 2022-06-21 02:11 SimoonJia 阅读(375) 评论(0) 推荐(0)
上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 37 下一页