Element框架中的Switch按钮在table表单无法使用问题

一、 今天在学习Element框架的时候遇到一个小坑,就是把Switch开关放到table标签里面,就无法使用了,经过漫长时间的查找发现这么写可以解决,

<el-table-column fixed="right" label="状态" width="150" height="50px">
      <template slot-scope='scope'>
       <el-switch
        style="display: block"
        v-model="value2"
        active-color="#13ce66"
        inactive-color="#ff4949"
        active-text="启用"
        inactive-text="禁用"
      >
      </el-switch>
       </template>
      </el-table-column>

但是这么写了以后他又出问题了,就是
image

大致意思就是:scope定义了没有被使用,对于一个前端小白来说,这个玩意怎么会报错呢,于是又开始一番搜索百度,终于功夫不负有心人让我找到了,问我发现这个slot-scope属性里面定义了值后还得在v-model里使用v-model="scope.row.自己定义的值",否则就会报错

 <template slot-scope='scope'>
       <el-switch
        style="display: block"
        v-model="scope.row.value2"
        active-color="#13ce66"
        inactive-color="#ff4949"
        active-text="启用"
        inactive-text="禁用"
      >
      </el-switch>
       </template>

加上以后,你就会发现小开关终于能用了,不容易啊,完结撒花✿✿ヽ(°▽°)ノ✿✿✿ヽ(°▽°)ノ✿

posted @   Primary丶  阅读(1509)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示