标签:doc new cal name fun har 文本 port 绑定
<!DOCTYPE html> <html lang="zh"> <head> <title></title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="https://unpkg.com/vue/dist/vue.js"></script> <link href="../css/style.css" rel="stylesheet"> </head> <body> <div id="myApp"> <div v-bind:class="{active:isActive}">红色文本1</div> <div :class="{active:isActive}">红色文本2</div> <button @click="btnClick">改变class吧</button> </div> <script> var myApp = new Vue({ el: ‘#myApp‘, data: { isActive: true, }, methods: { btnClick: function(){ this.isActive = !this.isActive; }, }, }); </script> </body> </html>
标签:doc new cal name fun har 文本 port 绑定
原文地址:https://www.cnblogs.com/Jeely/p/11057250.html