学无先后,达者为师

网站首页 Vue 正文

Vue+iview的表格选中数据点击编辑后,跳转到编辑页后将数据传值到输入框默认显示

作者:.WYc 更新时间: 2022-03-01 Vue

前言:在ivew表格中任选一条数据,在操作栏中点击‘编辑’图标,这里我没有用在行间编辑的方式,而是跳转到新的编辑页面,那么就需要路由传参到新的页面显示

1.首先给‘编辑’按钮绑定点击事件

        {
          title: '操作',
          key: 'action',
          width: 150,
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('Icon', {
                class: 'editHover',
                props: {
                  type: 'md-create',
                  size: 15
                },
                attrs: {
                  title: '编辑'
                },
                on: {
                  click: () => {
                    this.handleEdit(params.row)             //编辑方法
                  }
                }
              })
            ]);
          }
        }

 

2.然后在methods()中写这个方法:

    handleEdit (row) {
      this.$router.push(
        {
          path: '/*******',              //这里写要跳转的路径
          query: {
            info: row
          }
        });
    }

 

3.在要跳转的页面中先声明 infoGet: this.$route.query.info

 

4.打印是否接收到传过来的数组

  console.log('this.infoGet', this.infoGet);

 

5.接收到数组后要根据实际情况进行进一步判断,然后依次将得到的数据放入对应的输入框就可以了

原文链接:https://blog.csdn.net/weixin_42675298/article/details/90899355

栏目分类
最近更新