我正在尝试获得一个按钮,按下该按钮后会改变颜色。当再次按下时,它应该变回原来的颜色。我究竟做错了什么?
我的模板中的按钮:
<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 ×1