Vue 教程
/ 指令
指令
示例:v-bind
指令
浏览器从 Vue 实例中查找将 <div> 元素连接到哪个类。
<!DOCTYPE html> <html lang="en"> <head> <style> .pinkBG { background-color: lightpink; } </style> </head> <body> <div id="app"> <div v-bind:class="vueClass"></div> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ data() { return { vueClass: "pinkBG" } } }) app.mount('#app') </script> </body> </html> »注意: 如果没有 Vue 代码,上面的示例可以写得更简单,但请耐心等待。 当我们制作响应式页面时,可以在后面的示例中看到 Vue 的真正好处。