提交 99106b1c 编写于 作者: 郭胜强

解决mpvue-picker组件第一次不显示的问题。

上级 6e6dddeb
...@@ -33,32 +33,38 @@ export default { ...@@ -33,32 +33,38 @@ export default {
pickerValue: [0, 0, 0], pickerValue: [0, 0, 0],
provinceDataList: [], provinceDataList: [],
cityDataList: [], cityDataList: [],
areaDataList: [] areaDataList: [],
/* 是否显示控件 */
showPicker: false,
}; };
}, },
created() { created() {
this.handPickValueDefault(); // 对 pickerValueDefault 做兼容处理 this.init()
this.provinceDataList = provinceData;
this.cityDataList = cityData[this.pickerValueDefault[0]];
this.areaDataList =
areaData[this.pickerValueDefault[0]][this.pickerValueDefault[1]];
this.pickerValue = this.pickerValueDefault;
}, },
props: { props: {
/* 是否显示控件 */
showPicker: {
type: Boolean,
default: false
},
/* 默认值 */ /* 默认值 */
pickerValueDefault: { pickerValueDefault: {
type: Array, type: Array,
default: [0, 0, 0] default(){
return [0, 0, 0]
}
}, },
/* 主题色 */ /* 主题色 */
themeColor: String themeColor: String
}, },
watch:{
pickerValueDefault(){
this.init();
}
},
methods: { 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() { show() {
setTimeout(() => { setTimeout(() => {
this.showPicker = true; this.showPicker = true;
......
...@@ -78,7 +78,9 @@ ...@@ -78,7 +78,9 @@
pickerValueMulTwoTwo: [], pickerValueMulTwoTwo: [],
pickerValueMulThreeOne: [], pickerValueMulThreeOne: [],
pickerValueMulThreeTwo: [], pickerValueMulThreeTwo: [],
pickerValueMulThreeThree: [] pickerValueMulThreeThree: [],
/* 是否显示控件 */
showPicker: false,
}; };
}, },
props: { props: {
...@@ -87,20 +89,19 @@ ...@@ -87,20 +89,19 @@
type: String, type: String,
default: 'selector' default: 'selector'
}, },
/* 是否显示控件 */
showPicker: {
type: Boolean,
default: false
},
/* picker 数值 */ /* picker 数值 */
pickerValueArray: { pickerValueArray: {
type: Array, type: Array,
default: [] default(){
return []
}
}, },
/* 默认值 */ /* 默认值 */
pickerValueDefault: { pickerValueDefault: {
type: Array, type: Array,
default: [] default(){
return []
}
}, },
/* 几级联动 */ /* 几级联动 */
deepLength: { deepLength: {
...@@ -116,7 +117,10 @@ ...@@ -116,7 +117,10 @@
}, },
mode(oldVal, newVal) { mode(oldVal, newVal) {
this.modeChange = true; this.modeChange = true;
} },
pickerValueArray(val){
this.initPicker(val);
}
}, },
methods: { methods: {
initPicker(valueArray) { initPicker(valueArray) {
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
data() { data() {
return { return {
title : "mvpue-picker 使用示例", title : "mvpue-picker 使用示例",
pickerValueDefault: [0, 0],
pickerSingleArray: [{ pickerSingleArray: [{
label: '中国', label: '中国',
value: 1 value: 1
...@@ -58,7 +57,8 @@ ...@@ -58,7 +57,8 @@
pickerText: '', pickerText: '',
mode: '', mode: '',
deepLength: 1, deepLength: 1,
pickerValueDefault: [0] pickerValueDefault: [0],
pickerValueArray:[]
}; };
}, },
methods: { methods: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册