Skip to content
New issue

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

picker的value如何实现只设置一部分的值且可以更新 #348

Open
xmsz opened this issue Jan 19, 2021 · 1 comment
Open

picker的value如何实现只设置一部分的值且可以更新 #348

xmsz opened this issue Jan 19, 2021 · 1 comment

Comments

@xmsz
Copy link

xmsz commented Jan 19, 2021

DEMO:
https://github.com/xmsz/demo-20210119

核心部分就是

const state = [[],[]]

<picker value={state}>

</picker>

// 
state[0] = [];  // 这样的话是不会有更新的
//
state = [[],[]] // 这样才可以,就是必须要完整的赋值才行

所以希望可以只赋一部分的值,不过也不是特别的影响

@JuneAndGreen
Copy link
Collaborator

应该是这个原因:因为这里传的引用,只改引用里面的值的话,新旧都一样的,所以 diff 不出来差异。

后面我看看有没有必要加个深拷贝或者研究下有没有其他方案处理这种情况。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants