使用vue.js实现联动效果的示例代码
想用vue.js写一个联动效果,按照自己的思路实验了下,并没有成功。请大家指点下我的思路是:通过遍历YX数组,如果某个对象的text和第一个select的selected value相同,则显示对应院系的专业
<div id="test"> <select v-model="A"> <option v-for="yx in YX"> {{yx.text}} </option> </select> <select name="ZY"> <option v-for="zy in {{ selection }}"> {{zy.text}} </option> </select> </div> <script> new Vue({ el:'#test', data:{ YX:[ { text:'计信院', ZY:[ {text:'软件工程'}, {text:'计算机科学与技术'}, {text:"信息安全"}, ] }, { text:'商学院', ZY:[ {text:'旅游管理'}, {text:'工商管理'}, {text:"行政管理"}, ] }, ] }, computed:{ selection: { get: function() { var obj; var ZY = eval(this.YX) for(obj in ZY) { if(A == obj.text) B = obj.ZY } return B } } } }); </script>
相关推荐
wwzaqw 2020-11-11
kldy00 2020-11-03
VinFOSSIDce 2020-11-02
kldy00 2020-10-29
VinFOSSIDce 2020-10-28
nodid 2020-10-28
硕鼠 2020-10-26
TifaBest 2020-10-25
weigenzongderoot 2020-10-14
fzxhsaj 2020-10-14
xuyoucheng00 2020-09-26
网络菜市场 2020-09-23
Veechange 2020-09-01
VinFOSSIDce 2020-08-24
智链ChainNova 2020-08-17
Jantywei 2020-08-13
gcttong00 2020-08-13
gcttong00 2020-08-11
xiaoemo0 2020-08-09