console 命令行工具
X
clear
> Download the Vue Devtools extension for a better development experience:
https://github.com/vuejs/vue-devtools
> You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
console
new Vue({
el:"#app",
data:{
borderRadius:'0%',
isRed:true
},
methods:{
start:function(){
var vm=this
setInterval(function(){
vm.isRed=!vm.isRed;
},1000)
},
changeStyle:function(){
if(this.borderRadius=='50%'){
this.borderRadius='0%'
}else{
this.borderRadius='50%'
}
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<div id="app">
<div class="main" @click='changeStyle' :style="{'border-radius':borderRadius}"></div>
<button @click="start">开始</button>
<div class="main" :class="{red:isRed,blue:!isRed}"></div>
</div>
.main{height:150px;width:150px;background-color:gray}
.red{background-color:red}
.blue{background-color:blue}