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

[Cascader] 设置Value值无效 #2902

Closed
WEBTMM opened this issue Jun 25, 2024 · 4 comments · Fixed by #3142
Closed

[Cascader] 设置Value值无效 #2902

WEBTMM opened this issue Jun 25, 2024 · 4 comments · Fixed by #3142
Labels
question This is a question, not a bug

Comments

@WEBTMM
Copy link

WEBTMM commented Jun 25, 2024

这个功能解决了什么问题

使用场景:编辑用户资料,通过接口数据返回用户已选择的省市区信息,通过接口数据结果设置Cascader Value
预期效果:当用户点击省市区时默认选中数据接口返回的省市区选项
实际效果:Value本地写死可以默认选中项,通过接口数据设置Value无效

接口数据返回格式为:district: { code: 230108, name: "平房区" }
Value设置值为:district.code

你建议的方案是什么

通过数据接口Value可以设置默认选中项,更加方便用户以上次保存信息为基础变更新的选项信息

Copy link
Contributor

👋 @WEBTMM,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@anlyyao
Copy link
Collaborator

anlyyao commented Jun 25, 2024

@WEBTMM 收到反馈,我来看看~

@anlyyao
Copy link
Collaborator

anlyyao commented Jul 3, 2024

@WEBTMM hello 我这边初步在attached阶段使用setTimeout模拟接口异步数据,并在此同步赋值给value, cascader组件能正确响应,未能复现你的问题~。方便的话 希望能提供一下可复现代码片段

@anlyyao anlyyao added the question This is a question, not a bug label Jul 3, 2024
@bibiehy
Copy link

bibiehy commented Jul 30, 2024

@anlyyao 试过了,确实不行,setData() 后无效,具体如下
1、renderer: webview 使用skyline应该也一样不行
2、"tdesign-miniprogram": "^1.5.0"
3、把value值改为变量cityValue,
data:{ cityValue: '120119' },这样可以,
如果改成在 onLoad 中 setTimeout(() => { that.setData({ cityValue: '120119' }); }, 3000);,这样就不行了

正在用呢,赶紧发个版本吧,或者给个临时方法,我先用一下

image

忘记说了,直接复制的官方提供的例子测试的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is a question, not a bug
Projects
None yet
3 participants