ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
>[success] # 指令速览案例 [vue3 指令官方文档 速览 ](https://cn.vuejs.org/api/built-in-directives.html#v-text) >[danger] ##### 案例 ~~~html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> </head> <body> <div id="app"> <!-- 声明渲染 {{}}--> <div>{{counter}}</div> <!-- v-on 缩写@ 绑定事件 --> <button @click="addCounter">增加</button> <!-- v-bind 缩写: 动态绑定属性 --> <div> <span :title="counter">鼠标悬停</span> </div> <!-- v-model 用户输入双向绑定 --> <div> {{msg}} <input v-model="msg" /> </div> <!-- v-if 条件显示隐藏 --> <div v-if="flag">显示隐藏</div> <!-- v-show 显示隐藏 --> <div v-show="flag">显示隐藏</div> <!-- v-for 循环--> <ul> <li v-for="todo in todos">{{todo}}</li> </ul> </div> <!-- 引入vue cdn --> <script src="https://unpkg.com/vue@next"></script> <script> const handler = { data() { return { counter: 1, msg: '', flag: true, todos: [1, 2, 3, 4, 5], } }, methods: { addCounter() { ++this.counter }, }, } // 创建vue const vm = Vue.createApp(handler) vm.mount('#app') </script> </body> </html> ~~~