|
盒子点击改变背景颜色成渐变,再点击回到红色,现在不生效,麻烦大佬们给看看。
<template>
<view class="page">
<view class={'box '+(show?'red_bg':'')} @click="change"></view>
</view>
</template>
<style>
.page{
width: 100%;
height: 100%;
}
.box{
width: 100px;
height: 100px;
background: red;
margin-top: 300px;
}
.red_bg{
background: linear-gradient(to right,rgba(23,135,216,1),rgba(13,102,166,1));
}
</style>
<script>
export default {
name: 'test',
data(){
return {
show : false
}
},
methods:{
change(){
this.show = !this.show
}
}
}
</script>
|
|