小编hon*_*ake的帖子

如何改变按钮点击时的颜色?(视)

我正在尝试获得一个按钮,按下该按钮后会改变颜色。当再次按下时,它应该变回原来的颜色。我究竟做错了什么?

我的模板中的按钮:

<th><Button v-bind:class="{'white': !clicked, 'blue': clicked}" v-on:click ="!clicked" ></Button></th>


<script>
    export default {
        data: {

clicked: false
        }

    }

</script>

<style>
   .white {
       background-color: white;
       width: 200px;
       height: 200px;  

   }
   .blue {
       width: 200px;
       height: 200px;
       background-color: blue;

   }


</style>
Run Code Online (Sandbox Code Playgroud)

vue.js

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

vue.js ×1