element ui 在messageBox里的html中绑定事件
<template>
<div class="about">
<h1>This is an about page</h1>
<el-button type="primary" size="default" @click="onTest">测试</el-button>
<div>
</div>
</div>
</template>
<script>
export default {
name: 'about',
mounted() {
window.myFunction = this.myFunction;
},
methods: {
onTest(){
this.$confirm(`<div>此操作将永久删除该文件, 是否继续</div>?<button onclick='myFunction()'>查询</button>`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
dangerouslyUseHTMLString: true,
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
myFunction(){
alert('你好啊')
}
},
}
</script>
在绑定事件后需要在window对象中添加才可以触发

浙公网安备 33010602011771号