入门级指导:data()中的数据用于初始化(初始不显示对话框)。
ref 是否使用都不影响。
运行效果:
<template>
<el-button type="primary" @click="centerDialogVisible = true">
Click to open Dialog
</el-button>
<el-dialog
v-model="centerDialogVisible"
title="Notice"
width="30%"
destroy-on-close
center
>
<span>
Notice: before dialog gets opened for the first time this node and the one
bellow will not be rendered
</span>
<div>
<strong>Extra content (Not rendered)</strong>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="centerDialogVisible = false">Cancel</el-button>
<el-button type="primary" @click="submit()">
Confirm
</el-button>
</span>
</template>
</el-dialog>
</template>
<script>
export default {
name: 'AboutPage',
props: {
separator: {
type: String
}
},
data() {
return {
// centerDialogVisible : ref(false)
centerDialogVisible : false
}
},
methods:{
submit(){
console.log("提交...");
this.centerDialogVisible = false;
}
},
};
</script>
<style scoped>
.dialog-footer button:first-child {
margin-right: 10px;
}
</style>