运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,暗色/亮色
前往 Spaces
<!DOCTYPE html> <html> <head> <title>v-bind background-color</title> <style> #app > div { width: 200px; padding: 20px; border: dashed black 1px; } .myClass { background-color: lightcoral; } </style> </head> <body> <h1>Example</h1> <p>'v-bind' is used to assign class with true/false.</p> <p>The browser set the 'myClass' class on the div tag when set to 'true'.</p> <div id="app"> <div v-bind:class="{ myClass: true }"> Importance visualized by background color </div> </div> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <script> const app = Vue.createApp({ // The Vue instance is empty }) app.mount('#app') </script> </body> </html>