场景:
el-table中渲染数据后,选中某行,点击后面修改按钮,将该行数据填入弹出的表单中
效果图:


代码部分:
父组件中声明了子组件ref="addform",子组件中数据项v-model="form"

在按钮处,增加了<template scope="scope">,并在@click时以scope.row为入参

js的method中editForm实现如图,看最后一行this.$refs.addform.form = Object.assign(row),将row的数据传入子组件addform的form中,以达到子组件被调起的数据渲染
网友评论