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 的 default-index 的使用方法 #134

Closed 1847211504 closed 6 years ago

1847211504 commented 6 years ago

Mand Mobile Version

v 1.4.3

OS Version & Browser Version

windows chrome 67 64位

Node Version, Package Management Tool

Recurring Links

https://codesandbox.io/s/zxj3voq4xx

Recurring Steps

引入 picker 组件后,方法中动态修改 deaultIndex

Expectant Behaviors

索引按设置改变

Actual Behaviors

未改变,无论是否调用了 refresh 方法

xxyan0205 commented 6 years ago

因为第一次渲染完成后再动态修改deaultIndex picker并没有被重新渲染。 给picker增加一个key,每次defaultIndex改变的时候,通过更改key强制重新渲染。

<md-picker
      ref="picker"
      :data="picker.data"
      :title="picker.title"
      :default-index="picker.defaultIndex"
      :key="picker.defaultIndex"
      v-model="picker.show"
    ></md-picker>
1847211504 commented 6 years ago

收到,测试已通过,多谢