We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如果state中是数组变量,在修改数组中值后不会更新视图
import Taro, { Component } from '@tarojs/taro' import { View, Text } from '@tarojs/components' export default class Test extends Component { config = { navigationBarTitleText: '' } constructor() { super(...arguments) this.state = { abc:[] } } componentWillMount () { setTimeout(()=>{ this.setState({abc:[{a:1}]}) },1000) } click(){ let {abc} = this.state abc[0].a=2 this.setState({ abc }) } render () { const {abc} = this.state //在click后这里的abc已经打印出了2,但视图没变化 console.log('abc ',abc) return ( <View onClick={this.click.bind(this)}> {abc[0].a} </View> ) } }
可以及时更新视图
Taro v1.3.27
Taro CLI 1.3.27 environment info: System: OS: Windows 7 Binaries: Node: 10.12.0 - C:\Program Files\nodejs\node.EXE npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
The text was updated successfully, but these errors were encountered:
CC @Chen-jj
Sorry, something went wrong.
欢迎提交 Issue~
如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏
如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。
Good luck and happy coding~
0892241
fix(weapp): setData 前需要深拷贝衍生自 state 的 data, fix #5012
8c25b0d
对 state 的操作直接影响 data,因为 data 和 state 引用一样,因此需要深拷贝再 setData。 去除 shakeFnFromObject 的锅。
Chen-jj
No branches or pull requests
问题描述
如果state中是数组变量,在修改数组中值后不会更新视图
期望行为
可以及时更新视图
系统信息
Taro v1.3.27
Taro CLI 1.3.27 environment info:
System:
OS: Windows 7
Binaries:
Node: 10.12.0 - C:\Program Files\nodejs\node.EXE
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
The text was updated successfully, but these errors were encountered: