diff --git a/examples/hello-uniapp/components/mpvue-citypicker/mpvueCityPicker.vue b/examples/hello-uniapp/components/mpvue-citypicker/mpvueCityPicker.vue index 01b1441f282b7964fab627189ef1a14223cdc19f..2a0416c31e138e35bec472974484f20a215f7549 100644 --- a/examples/hello-uniapp/components/mpvue-citypicker/mpvueCityPicker.vue +++ b/examples/hello-uniapp/components/mpvue-citypicker/mpvueCityPicker.vue @@ -33,32 +33,38 @@ export default { pickerValue: [0, 0, 0], provinceDataList: [], cityDataList: [], - areaDataList: [] + areaDataList: [], + /* 是否显示控件 */ + showPicker: false, }; }, created() { - this.handPickValueDefault(); // 对 pickerValueDefault 做兼容处理 - this.provinceDataList = provinceData; - this.cityDataList = cityData[this.pickerValueDefault[0]]; - this.areaDataList = - areaData[this.pickerValueDefault[0]][this.pickerValueDefault[1]]; - this.pickerValue = this.pickerValueDefault; + this.init() }, props: { - /* 是否显示控件 */ - showPicker: { - type: Boolean, - default: false - }, /* 默认值 */ pickerValueDefault: { type: Array, - default: [0, 0, 0] + default(){ + return [0, 0, 0] + } }, /* 主题色 */ themeColor: String }, + watch:{ + pickerValueDefault(){ + this.init(); + } + }, methods: { + init() { + this.handPickValueDefault(); // 对 pickerValueDefault 做兼容处理 + this.provinceDataList = provinceData; + this.cityDataList = cityData[this.pickerValueDefault[0]]; + this.areaDataList = areaData[this.pickerValueDefault[0]][this.pickerValueDefault[1]]; + this.pickerValue = this.pickerValueDefault; + }, show() { setTimeout(() => { this.showPicker = true; diff --git a/examples/hello-uniapp/components/mpvue-picker/mpvuePicker.vue b/examples/hello-uniapp/components/mpvue-picker/mpvuePicker.vue index 8a0123ba7f1176fd1e5a89ef04467cf7f3258052..dd988296f9e67f25fc78787cb1d5a779a75956f2 100644 --- a/examples/hello-uniapp/components/mpvue-picker/mpvuePicker.vue +++ b/examples/hello-uniapp/components/mpvue-picker/mpvuePicker.vue @@ -78,7 +78,9 @@ pickerValueMulTwoTwo: [], pickerValueMulThreeOne: [], pickerValueMulThreeTwo: [], - pickerValueMulThreeThree: [] + pickerValueMulThreeThree: [], + /* 是否显示控件 */ + showPicker: false, }; }, props: { @@ -87,20 +89,19 @@ type: String, default: 'selector' }, - /* 是否显示控件 */ - showPicker: { - type: Boolean, - default: false - }, /* picker 数值 */ pickerValueArray: { type: Array, - default: [] + default(){ + return [] + } }, /* 默认值 */ pickerValueDefault: { type: Array, - default: [] + default(){ + return [] + } }, /* 几级联动 */ deepLength: { @@ -116,7 +117,10 @@ }, mode(oldVal, newVal) { this.modeChange = true; - } + }, + pickerValueArray(val){ + this.initPicker(val); + } }, methods: { initPicker(valueArray) { diff --git a/examples/hello-uniapp/pages/template/mpvue-picker/mpvue-picker.vue b/examples/hello-uniapp/pages/template/mpvue-picker/mpvue-picker.vue index fa9ce1669c1957442ec5c7300c10077681030f44..114340e3225a9111e750e7d21f2947cda0c6bd37 100644 --- a/examples/hello-uniapp/pages/template/mpvue-picker/mpvue-picker.vue +++ b/examples/hello-uniapp/pages/template/mpvue-picker/mpvue-picker.vue @@ -34,7 +34,6 @@ data() { return { title : "mvpue-picker 使用示例", - pickerValueDefault: [0, 0], pickerSingleArray: [{ label: '中国', value: 1 @@ -58,7 +57,8 @@ pickerText: '', mode: '', deepLength: 1, - pickerValueDefault: [0] + pickerValueDefault: [0], + pickerValueArray:[] }; }, methods: {