用vue-cli搭建项目的 vue关于 :class 和 v-if ,v-show

template:

 

<div @click="up">

<span :class="{colors:isactive===false }"  v-if="isactive===false" >上线</span>

<span :class="{colors2:isactive===true}"  v-if="isactive===true"  >下线</span>

</div>

<div v-if="isactive===false">

<span>编辑</span>

<span>删除</span>

</div>

 

script:

data():{

return{

      //res.results[i].type=1那么res.results[i].type===1

isactive:'',//后台传入数据判断 :if(res.results[i].type===true){this.isactive=true}else{this.isactive=false}

}

}

style:

.colors{

color:red

}

.colors2{

color:green;

}

 

posted @ 2019-02-21 13:54  我就是要叫鱼摆摆  阅读(1900)  评论(0)    收藏  举报