element-ui 中Switch的用法

在element-ui中,如果你想知道Switch是开还是关,使用事件 @change="getchange(value2)"
它会输出true或者false。true代表的是开,false代表的是关。

<template>
  <div>
    <el-switch
      v-model="value2"
      active-color="red"
      @change="getchange(value2)"
      inactive-color="#0033aa"
    ></el-switch>
    <div>{{obg.info}}</div>
    <el-button type="primary" @click="getclick">主要按钮</el-button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      msg: "123",obg: {
        info: "12"
      },value2: true
    };
  },methods: {
    getchange(mess) {
      console.log(mess); //输出true或者false
      this.value2 = mess; //赋值
    },getclick() {
      console.log(this.value2);
      if (this.value2 && this.obg.info) { //这里使用的是&&运算 两个条件同时满足
        this.$message({
          message: "该同学已经有水卡",type: "success"
        });
      }
    }
  }
};
</script>

相关文章

el-menu 有个属性 :default-active="curActive"...
基础用法1<el-inputv-model="input1"palcehode...
 1.安装element-uinpminstallelement-ui-S 2.在main.js中i...
layout布局通过基础的24分栏,可进行快速布局基础布局使用单...
 今天做一个选择年份的功能,直接调用了ElementUI里面的Dat...
  that.end 即为结束日期