iview tabs里面放入 i-switch slot的写法

简介: iview tabs里面放入 i-switch slot的写法
        {
          'title': '状态',
          'key': 'status',
          render: (h, params) => {
            return h(
              'i-switch',
              {
                props: {
                  trueValue: 1,
                  falseValue: 0,
                  beforeChange: () => {
                    // if (status === 0)
                    console.log(params.row.status)
                    if (params.row.status === 1) {
                      console.log('000')
                      return new Promise((resolve) => {
                        this.$Modal.confirm({
                          title: '确认停用',
                          content: '停用商品后,该商品将不允许继续被选择,但不影响当前售卖。如果希望取消商品售卖,请在售货机详情中进行操作。',
                          onOk: () => {
                            this.changeStatus(params.row.status, params.row.id)
                          }
                        })
                      })
                    } else {
                      console.log('111')
                      this.changeStatus(params.row.status, params.row.id)
                    }
                  },
                  value: Number(params.row.status),
                  size: 'large'
                }
              },
              [
                h('span', {
                  slot: 'open'
                }, '启用'),
                h('span', {
                  slot: 'close'
                }, '停用')
              ]
            )
          }
        },
    render:(h,params)=>{
        return h('i-switch',{
            props:{
                value:params.row.status
                size:'large'
            },
            scopedSlots:{
                open:()=>h('span','开启'),
                close:()=>h('span','停用')
            }
        })
    }

相关文章
|
10月前
layui嵌套弹出模态框的Blocked a frame with origin null from的解决方案
layui嵌套弹出模态框的Blocked a frame with origin null from的解决方案
121 0
|
8月前
|
JavaScript
element-ui(vue版)使用switch时change回调函数中的形参传值问题
element-ui(vue版)使用switch时change回调函数中的形参传值问题
72 0
|
JavaScript 数据格式
VUE element-ui下拉菜单el-select获取label值或value的值
VUE element-ui下拉菜单el-select获取label值或value的值
1552 0
VUE element-ui下拉菜单el-select获取label值或value的值
element-ui table排序sortable三种状态,怎么去掉默认状态
在 element-ui 中,也定义了 sort-orders 有三种状态: ascending、descending、null,这三种状态形成一个循环切换。
2230 0
|
4天前
|
JavaScript 前端开发 开发者
button 元素的 disabled 属性用法
button 元素的 disabled 属性用法
16 3
|
7月前
|
JavaScript
vue项目在点击重复路由时报错(NavigationDuplicated: Avoided redundant navigation to current location)
vue项目在点击重复路由时报错(NavigationDuplicated: Avoided redundant navigation to current location)
58 2
|
7月前
【element-ui用法】el-radio-group默认选择和数据回显问题的解决方案
【element-ui用法】el-radio-group默认选择和数据回显问题的解决方案
239 0
|
小程序
【微信小程序】tabbar报错Component is not found in path “custom-tab-bar/index“
【微信小程序】tabbar报错Component is not found in path “custom-tab-bar/index“
287 0
|
JavaScript 前端开发
Vue3:elementplus表格header-cell-class-name回调方法使用
Vue3:elementplus表格header-cell-class-name回调方法使用
756 0
Vue3:elementplus表格header-cell-class-name回调方法使用