当第一级选择后才会渲染出第二级。第三级同样。但是现在我要一上来就去加载好三个级别。并且可以修改。
2.下面是代码
address2 = new Vue({
el: "#provincial2",
data: {
address2: "",
selected12: "",
selected13: "",
data2: ""
},
computed: {
selected_tow2:function() {
var selected_tow2 = [];
selectedDepart2 = this.$data.selected12;
this.$data.address2.forEach(function(c) {
if(c.name == selectedDepart2) {
selected_tow2 = c.children
};
});
address2.$set("data2", selected_tow2);
return selected_tow2;
},
selected_three2: function() {
var selected_three2 = [],
selectedDepart3 = this.$data.selected13;
this.$data.data2.forEach(function(d) {
if(d.name == selectedDepart3) {
selected_three2 = d.children
};
});
return selected_three2;
}
}
});
$.getJSON("address.json", function(result) {
address2.address2 = result.data.china;
});
<div class="user_information_nr" id="provincial2">
<select class="information_text" id="selected11" v-model="selected12">
<option v-for="provincial2 in address2" v-bind:id="provincial2.id" v-html="provincial2.name"></option>
</select>
<select class="information_text" id="selected12" v-model="selected13">
<option v-for="provincial_tow2 in selected_tow2" v-bind:id="provincial_tow2.id" v-html="provincial_tow2.name"></option>
</select>
<select class="information_text" id="selected13">
<option v-for="provincial_three2 in selected_three2" v-bind:id="provincial_three2.id" v-html="provincial_three2.name"></option>
</select>
</div>
现在的状态是加载好第一级。而我获取到数据。然后修改第一级的地址。然后在把第二级加载出来。然后在修改第二级。然后把第三级加载出来。然后修改第三级的地址
刚入行的菜鸟。非常业余。第一次问问题= =
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…