忻州 建网站,wordpress app 加载慢,手机网站建设要注意哪些问题,网站建立分站在做后台的时候需要用到地区级联选择器 然后就自己封装了一个
其中 组件页面中
export default {props: { //使用value接收引用页面的绑定值value: [String]},watch: {value: {handler(val) {//val 以及 this.value 都可以获取到引用页面的绑定值},deep: true,immediate: tr…在做后台的时候需要用到地区级联选择器 然后就自己封装了一个
其中 组件页面中
export default {props: { //使用value接收引用页面的绑定值value: [String]},watch: {value: {handler(val) {//val 以及 this.value 都可以获取到引用页面的绑定值},deep: true,immediate: true}},
}
//this.$emit(input, this.changeForm()); 这句代码是给引用页面绑定值返回内容完整地区json文件在网盘中
链接https://pan.quark.cn/s/0b70e60fd377 提取码4sSe
下面是完整代码
引用页面中
select-address v-modelform.applicableRange/main.js中注册组件
import SelectAddress from /components/SelectAddressVue.component(SelectAddress, SelectAddress)组件页面
templatediv classselectAddressel-form :modelformel-select v-modelform.provincial changeupdateProvincials() clearableplaceholder请选择省份el-option v-forprovincial in provincials :keyprovincial.label :valueprovincial.label:labelprovincial.label//el-selectel-select v-modelform.municipal changeupdateMunicipals()placeholder请选择城市el-option v-formunicipal in municipals :keymunicipal.label :valuemunicipal.label:labelmunicipal.label//el-selectel-select v-modelform.regional changeupdateRegionals()placeholder请选择地区el-option v-forregional in regionals :keyregional.label :valueregional.label:labelregional.label//el-selectel-select v-modelform.streets changeupdateStreetss()placeholder请选择街道el-option v-forstreets in streetss :keystreets.label :valuestreets.label :labelstreets.label//el-select/el-form/div
/template
script
const options require(/assets/images/pcas-code.json);
export default {props: {value: [String]},data() {return {form: {provincial: null,municipal: null,regional: null,streets: null,},provincials: options,municipals: [],regionals: [],streetss: [],}},watch: {value: {handler(val) {if (val) {const list this.value.split( );if(list.length 1){this.form.provincial list[0];this.updateProvincials();}else if(list.length 2){this.form.provincial list[0];this.updateProvincials();this.form.municipal list[1];this.updateMunicipals();}else if(list.length 3){this.form.provincial list[0];this.updateProvincials();this.form.municipal list[1];this.updateMunicipals();this.form.regional list[2];this.updateRegionals();}} else {this.reset();return [];}},deep: true,immediate: true}},mounted() {},created() {},computed: {},methods: {reset() {this.form {provincial: null,municipal: null,regional: null,streets: null}},updateProvincials() {this.form.municipal ;this.form.regional ;this.form.streets ;this.municipals [];this.regionals [];this.streetss [];this.$emit(input, this.changeForm());if(this.form.provincial){this.municipals this.provincials.find(provincial provincial.label this.form.provincial).children;}},updateMunicipals() {this.form.regional ;this.form.streets ;this.regionals [];this.streetss [];this.$emit(input, this.changeForm());this.regionals this.municipals.find(municipal municipal.label this.form.municipal).children;},updateRegionals() {this.form.streets ;this.streetss [];this.$emit(input, this.changeForm());this.streetss this.regionals.find(regional regional.label this.form.regional).children;},updateStreetss() {this.$emit(input, this.changeForm());},changeForm(){let applicableRange ;if(this.form.provincial){applicableRange this.form.provincial}if(this.form.provincial this.form.municipal){applicableRange this.form.provincial this.form.municipal}if(this.form.provincial this.form.municipal this.form.regional){applicableRange this.form.provincial this.form.municipal this.form.regional}if(this.form.provincial this.form.municipal this.form.regional this.form.streets){applicableRange this.form.provincial this.form.municipal this.form.regional this.form.streets}return applicableRange;}},
}
/scriptstyle scoped langscss
.el-select {width: 18%;margin-left: 1%;
}
/style