<template>
<el-button type="text" @click="open">点击打开 Message Box</el-button>
</template>
<script>
export default {
methods: {
open() {
this.$alert('这是一段内容', '标题名称', {
confirmButtonText: '确定',
callback: action => {
this.$message({
type: 'info',
message: `action: ${ action }`
});
}
});
}
}
}
</script>
但是在使用时报了this.$alert is not a function
解决办法:
在element.js中加入Vue.prototype.$XXX = MessageBox
this.$MessageBox.alert('这是一段内555565容', '标题名称', {
confirmButtonText: '确定',
callback: action => {
this.$message({
type: 'info',
message: '66666666666666'
});
}
});