iview render input 每输入一个字符就会自动跳出焦点

10 篇文章 0 订阅

今天遇到的bug,博客有空补上
在写iview render函数时,刚开始是按照下边代码写的,这样input输入的一个字符就是失焦。
原因:

{
          title: "注意交接事项",
          key: "handler",
          render: (h, params) => {
            return h("Input", {
              props: {
                value: params.row.matterAttention,
                placeholder: "请输入注意事项",
                size: "small"
              },
              on: {
               		input: e => {
                    //params.row.matterAttention = e.target.value;
                    this.tableData[params.index].matterAttention = e;
                }
              }
            });
          }
        }

方法:
表格是绑定的table的数据是tableData,input数据改变的时候你把整行的数据替换掉,就不会造成table重新渲染,导致input失焦了

{
          title: "注意交接事项",
          key: "handler",
          render: (h, params) => {
            return h("Input", {
              props: {
                value: params.row.matterAttention,
                placeholder: "请输入注意事项",
                size: "small"
              },
              on: {
               'on-change': e => {
                    params.row.matterAttention = e.target.value;
                    this.tableData[params.index] = params.row;
                }
              }
            });
          }
        }
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值