element ui 的messageBox中绑定vnode节点
<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',
data() {
return {
time:5,
number:1235455
}
},
mounted() {
window.myFunction = this.myFunction;
},
methods: {
onTest(){
const h = this.$createElement;
// this.$confirm(`<div>此操作将永久删除该文件, 是否继续</div>?<button onclick='myFunction()'>查询</button>`, '提示', {
this.$confirm( h('div', null, [`此操作将${this.time}分钟后永久删除该文件${this.number}, 是否继续`,
h('el-button', {on: {
click: this.myFunction
},attrs: {
type: 'text'
},}, '查询 ',),
h('i', { style: 'color: teal' }, 'VNode')
]), '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
dangerouslyUseHTMLString: true,
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
myFunction(){
alert('你好啊')
}
},
}
</script>
深入数据对象
有一点要注意:正如 v-bind:class 和 v-bind:style 在模板语法中会被特别对待一样,它们在 VNode 数据对象中也有对应的顶层字段。该对象也允许你绑定普通的 HTML attribute,也允许绑定如 innerHTML 这样的 DOM property (这会覆盖 v-html 指令)。
|

浙公网安备 33010602011771号