didi / mand-mobile

💰 A mobile UI toolkit, based on Vue.js 2, designed for financial scenarios.
https://didi.github.io/mand-mobile
Apache License 2.0
3.46k stars 772 forks source link

picker多级联动 #283

Closed I-Liyang closed 5 years ago

I-Liyang commented 5 years ago

Mand Mobile Version

OS Version & Browser Version

Recurring Links

Recurring Steps

多级联动时我的数据是从后台请求的,已经获取到数据(json有值),但是不刷新数据,需要重新弹出来选择器才有数据

Expectant Behaviors

获取到数据时刷新队列

Actual Behaviors

获取到数据不刷新队列

xxyan0205 commented 5 years ago

哪个版本?

xxyan0205 commented 5 years ago

https://mand-mobile.github.io/2x-doc/#/zh-CN/docs/components/feedback/picker?anchor=refresh%28callback,%20startColumnIndex%29

I-Liyang commented 5 years ago

就是最新的版本,可能是我写法有问题,我的操作是给数组重新赋值,请问还需要进行什么操作吗,我的数据模仿的是https://github.com/didi/mand-mobile/blob/master/components/picker/demo/data/district.js这个js的数据

xxyan0205 commented 5 years ago

赋值完后要调用refresh方法重新初始化,或给picker增加key赋值完后修改key值。

this.$nextTick(() => {
   this.$refs.picker.refresh()
})
I-Liyang commented 5 years ago

调用refresh方法初始化的时候会一直默认选中第一条数据,增加key的方法会出现选择框一直重新弹出的问题

xxyan0205 commented 5 years ago

refresh方法和改变key都是重新初始化组件,包括数据源和默认选中,但是这个得根据你的具体情况加一些状态锁,在合适的时机调用