方法一:
首先:写一个封装的弹窗组件。
- <template>
- <el-dialog
- :visible.sync="dialogVisible"
- :fullscreen="true"
- v-bind="$attrs"
- v-on="$listeners"
- custom-class="previewDialog"
- :modal="false"
- >
- <p>弹窗</p>
- </el-dialog>
- </template>
-
- <script>
-
- export default {
-
- data() {
- return {
- dialogVisible: false
-
- };
- },
- created() {},
-
- methods: {
- init(roleId = null) {
- this.dialogVisible = true;
-
- },
-
- },
- };
- </script>
- <style lang="scss" scoped>
-
- </style>
-
使用:
<scene-add-update ref="sceneAddUpdate" />
打开弹窗
this.$refs.sceneAddUpdate.init(); // 调用方法