vue实现的下拉框功能示例

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> vue下拉框</title> <script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script> </head> <body> <div> <select v-model="one"> <option v-for="x in shuju">{{x.name}}{{x.famname}}</option> </select><br> <div> <span>{{one}}</span><br> <span>{{oneF}}</span><br> <span>{{oneL}}</span> </div> </div> <script> let rua=new Vue({ el:"#app", data:{ shuju:[ {name:"孙",famname:"悟空"}, {name:"猪",famname:"八戒"}, {name:"沙",famname:"悟净"} ], one:"" }, computed:{ oneF(){ return this.one.charAt(0); }, oneL(){ return this.one.slice(1,3); } } }); </script> </body> </html>

这里使用在线HTML/CSS/JavaScript代码运行工具测试上述代码,可得如下运行结果:

vue实现的下拉框功能示例

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/c031f39a14957a53e72acc53c04e6c06.html