dialog中有个子组件,新增和编辑都会使用该组件,现在遇到的问题是完成一次新增/编辑操作之后再次打开dialog的时候,表单中还残留着上一次填写的数据,有没有办法在dialog每次显示的时候根据action做一次“初始化”来清空一下data?
<el-dialog title="提示" :visible.sync="dialogVisible"
在dialog上面添加v-if='dialogVisible'
<el-dialog title="提示" :visible.sync="dialogVisible" v-if='dialogVisible'
这样就初始化了
原因:加载v-if之后,在每次加载modal的情况下,会重新渲染一遍页面元素,因此会重新请求数据