扫码关注官方订阅号
假设html如下:
html
<p id="app"> <ul> <li v-for="todo in todos"> {{ todo.text }} </li> </ul> <ul class="list2"> <li v-for="item in items"> {{ item.text }} </li> </ul> </p>
javascript如下:
new Vue({ el: '#app', data: { todos: [ { text: 'Learn JavaScript' }, { text: 'Learn Vue.js' }, { text: 'Build Something Awesome' } ], items: [ { text: 'Learn React' }, { text: 'Learn Angular.js' }, { text: 'Build Something Cool!' } ] } })
所以你的问题是,没理解数据驱动什么意思吧?入口只绑定#app就好了,剩下的靠数据驱动UI就好了。
#app
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
假设
html如下:javascript如下:
所以你的问题是,没理解数据驱动什么意思吧?入口只绑定
#app就好了,剩下的靠数据驱动UI就好了。