• vue elementui switch开关控件的使用


    <el-switch @change="test" on-value="1" off-value="0" v-model="value1">
    data () {
        return{
            value1: '1'
        }
    }
    methods:{
        test (val) {
            console.log(val)
        }
    }

    element-ui的table和switch相组合,写了个例子:

    <el-table
        :data="csData"
        tooltip-effect="dark"
        border
        stripe
        style=" 100%">
        <el-table-column type="index" label="序号" align="center" width=""></el-table-column>
        <el-table-column prop="name" label="名称" header-align="center" align="right"></el-table-column>
        <el-table-column label="操作" align="center" width="">
          <template slot-scope="scope">
            <el-switch
              v-model="scope.row.on"
              on-color="#00A854"
              on-text="启动"
              on-value="1"
              off-color="#F04134"
              off-text="禁止"
              off-value="0"
              @change="changeSwitch(scope.row)">
            </el-switch>
          </template>
        </el-table-column>
    </el-table>
    data () {
        return {
          csData: [
            {
              name: '一',
              on: '0'
            },
            {
              name: '二',
              on: '1'
            }
          ]
        }
    }
    methods:{
        changeSwitch (data) {
          console.log(data)
        }
    }

    效果如下:

    原始数据第一行是,on是'0',点击后console出来,发现值改变了

    再点一次,又对应改变了

    总结一下,@change="func"是默认传过来的就是对应的on值,@change="func(data)"如果是某一条数据的完整的data

  • 相关阅读:
    终于找到一个在IE8下可以使用搜索栏的输入法了
    在psp中播放电脑上的flv文件
    屏蔽红警3强制升级
    在windows7中安装了office了
    Flv视频编辑软件FlvEditor
    射杀恋人之日
    USB口不够用了
    年底了,游戏大作连连
    又一个好用的xbox360手柄驱动
    Windows7体验小记
  • 原文地址:https://www.cnblogs.com/mr-wuxiansheng/p/8859198.html
Copyright © 2020-2023  润新知