企业🤖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> ~~~