import address from '../data/address'; export default { data(){ return { data:{ province:[], city:[], area:[], }, province:[], city:[], area:[], vValue:[] } }, watch:{ value:{ handler:function (value) { return this.setValue(value); }, immediate:true } }, methods:{ open:function(){ if (this.storeValueTarget && this.storeValueTarget.join('') !== this.vValue.join('')) { this.vValue = this.storeValueTarget; this.changeLevel('0',0); } }, /* 点击确认触发 */ confirm:function(){ let code = '0'; let cCode = []; let cAddress = []; this.vValue.map((item,index)=>{ code = this.getCode(index,code); if (address[code]&&address[code][item]) { cAddress.push(address[code][item].name); code = address[code][item].code; cCode.push(code); } }); this.storeValue = cAddress.join(''); this.storeValueTarget = [...this.vValue]; if (this.$attrs.input) { this.$emit('input',cAddress); } if (this.$attrs.onChange) { this.$emit('change',{ postcode: code, code: cCode, value: cAddress }); } }, /* 更改展示数据 */ changeLevel:function(code = '0',level=0){ let parentCode = code; let nowCode = ''; for (let i=level;i