vue组件中 IS 用法

//html
<link rel="stylesheet" href="http://www.jq22.com/demo/animate-141106223642/animate.min.css" />
<script src="//cdn.bootcss.com/vue/1.0.24/vue.min.js"></script>
<div id="app">
  <span class="area1" @click="isGet(1)" :class="[c1]">tap1</span>
  <span class="area1" @click="isGet(2)" :class="[c2]">tap2</span>
  <span class="area1" @click="isGet(3)" :class="[c3]">tap3</span>
  <component :is="keet" keep-alive  class="animated" transition="bounce" transition-mode="out-in" ></component>
</div>
//js
 Vue.transition("bounce", {
 enterClass: '',
 leaveClass: 'bounceInLeft'
 })
   
new Vue({
  el:'#app',
  data:{
    keet:"first",
    c1:'add_active',
    c2:'',
    c3:''
  },
  methods:{
    isGet:function(val){
      switch(val){
        case 1:this.keet = "first";this.c1='add_active';
          this.c2="";this.c3="";break;
        case 2:this.keet = "second";this.c1="";this.c2="add_active";
          this.c3="";break;
        case 3:this.keet = "third";this.c1="";this.c2="";
          this.c3="add_active";break;
      }
    }
  },
  components:{
    first:{
      template:"<div>1</div>"
    },
    second:{
      template:"<div>2</div>"
    },
    third:{
      template:"<div>3</div>"
    }
    
  },
  ready:function(){
  
  }
       
})
//css
.area1{display:inline-block;width:80px;height:80px;border:1px solid #ccc;}
div div{width:200px;height:200px;background:#abcdef;line-height:200px;
margin-top:20px;text-align:center;font-size:30px;}
.add_active{border:1px solid #f00;}

//预览结果

 

转载于:https://www.cnblogs.com/zhujiasheng/p/6337251.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值