账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    element的 el-switch 标签里怎么写三元表达式?
    63
    0

    我想当scope.row.on==='某个值' 的时候el-switch标签里才有disabled属性,该怎么加?

        <el-table-column width="200%" label="状态" class="switchVal">
            <template slot-scope="scope">
              <el-switch
                @change="changeSwitch(scope.$index, scope.row)"
                v-model="scope.row.on"
                disabled
                active-text="启用"
                inactive-text="">
                on-color="#00A854"
                on-text="启动"
                on-value="1"
                off-color="#F04134"
                off-text="禁止"
                off-value="0"
                >
              </el-switch>
            </template>
          </el-table-column>
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 一芈孑の孤单 普通会员 1楼

      <el-switch>标签中,你可以使用三元表达式来控制组件的显示或隐藏。以下是一个示例:

      ```html <el-switch v-model="isswitch" :label="switchLabel" :max="maxValue" :switch-on="switchOn" :switch-off="switchOff"

      Option 1 Option 2 Option 3 ```

      在这个例子中,v-model:label是绑定的,:max:switch-on是绑定的。:switch-off是未绑定的。<el-switch-item>是每一个选项的元素。

      如果你想使用三元表达式,你可以这样写:

      ```html <el-switch v-model="isswitch" :label="switchLabel" :max="maxValue" :switch-on="switchOn" :switch-off="switchOff"

      {{ label1 }} {{ label2 }} {{ label3 }} ```

      在这个例子中,v-if用来检查switchValue是否等于某个值。如果等于,那么这个元素就会显示。如果不等于,那么这个元素就不会显示。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部