iveiw:Switch开关用法

1、HTML

<Table border :columns="tableColumns" :data="tableData" :loading="tableLoading">
    <!-- 是否开启:0:启用,1:禁用 -->
    <template slot-scope="{ row, index }" slot="isStatus">
        <i-switch v-model="row.isStatus1" @on-change="handleChange(row)">
            <span :slot="0"></span>
            <span :slot="1"></span>
        </i-switch>
    </template>
</Table>

2、JS

export default {
    data() {
        return {
        	tableColumns:[
			   {
			        title: '序号',
			        type: 'index',
			        align: 'center',
			        width:"80"
			    },{
			        title: '状态',
			        key: 'isStatus',//是否开启:0:启用,1:禁用
			        align: 'center',
			        slot: 'isStatus'
			    }
			]
        }
    },
    methods: {
		getTableData(){
           dragonListApi.getRulesPage().then(res=>{
               if(res.code==0){
                   var resData = res.data.records;
                   resData.forEach((ele)=>{
                   	//接口返的状态是0--启用,1--禁用。Switch组建的v-modal值为bool,所以需要转一下。
                       ele.isStatus1 = ele.isStatus===0 ? true : false
                   })
                   this.tableData = resData
               }else{
                   this.$Message.error({
                       content: res.message,
                       duration: 1.5,
                       closable:true,
                   });
               }
           }).catch((error)=>{
               console.log(error)
               that.$Message.error({
                   content: error,
                   duration: 1.5,
                   closable:true,
               });
           })
       },
	}
}
	

3、效果图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值