使用vue更改点击背景的颜色

问题描述 投票:0回答:1

我想在点击时将背景颜色从蓝色更改为另一种颜色。这是我到目前为止所做的,但是没有用。

HTML

<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<div id="app">
<button v-on:click="dissapear" id="bluebaloon">

</button>
</div>

CSS

#bluebaloon{
  background-color:blue;
  height:100px;
  width:100px;
  border-radius:50px;
}

JS

var app = new Vue({
el :'#app',
methods:{
dissapear: function(){
this.dissapear.style.backgroundColor = "red";
}
}

}); 
javascript vue.js
1个回答
0
投票

尝试使用VueJs反应性来更改样式:

© www.soinside.com 2019 - 2024. All rights reserved.