const that = this
(保证你的作用域能传递到里边)
出现这个情况就类似,一个大房间(this),然后你手里拿着个扳手(resetForm),然后大房间内还有个封闭的小房间(闭包函数),小房间里的人喊着要扳手(resetForm)但是根本找不到扳手,那么只能喊大房间外边的你递扳手,所以小房间和大房间要拉根联系的电话线,传递消息(let 变量名 = this),拉通了,才能喊你递扳手进小房间(变量名.resetForm)去使用
MessageBox 组件相关
<script> export default { methods: { open() { this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { this.$message({ type: 'success', message: '删除成功!' }); }).catch(() => { this.$message({ type: 'info', message: '已取消删除' }); }); } } } </script>