iview踩坑记录(使用iview组件你不得不看的坑点和妙用指南!)

iview踩坑记录

清空组件的方法

清空DatePicker(日期选择器)的方法:

this.$refs.DatePicker.handleClear()

清空TimePicker(时间选择器)的方法:

this.$refs.TimePicker.handleClear()

清空Select组件的方法:

this.$refs.Select.clearSingleSelect()

清空Table组件的方法:

this.$refs.Table.selectAll(flase)

批量删除

利用promise.all和Table组件的@on-selection-change结合实现批量删除

<tables
        ref="manage_table"
        :loading="t_loading"
        editable
        v-model="tableData"
        :columns="columns"
        @on-selection-change='onSelectionChange'
        />
// 选择Table选项触发事件
onSelectionChange (row) {
   
      console.log(row)
      this.currentId = []
      for (let i = 0; i < row.length; i++) {
   
        this.currentId[i] = row[i].id
      }
      console.log(this.currentId)
    }
// 点击删除触发事件
onBanConfirm () {
   
      let rm = []
      for (let i = 0; i < this.currentId.length; i++) {
   
      // remove函数为一个Promise对象,调用后端接口实现删除
        rm.push(remove(this.currentId[i]))
      }
      Promise.all(rm)
        .then(res => {
   
          for (let i = 0; i < this.currentId.length; i++) {
   
            if (res[i].data.code !== 0) {
   
              this.$Message.error('系统错误')
              // 初始data中定义rm_result为true,只有返回错误的值才会更改为false
              this.rm_result = false
              break
            }
          }
          
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值