Commit ea1335dc by luyt

feat:修复GLDialog添加到body的问题

1 parent e5da3922
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
<el-button plain @click="testDialog3">dialog(中)无按钮</el-button> <el-button plain @click="testDialog3">dialog(中)无按钮</el-button>
<el-button plain @click="testBeforeDialog">之前小弹窗</el-button> <el-button plain @click="testBeforeDialog">之前小弹窗</el-button>
<!-- :content="'hello HelloWorld'" --> <!-- :content="'hello HelloWorld'" -->
<GLDialog :mode="mode" bigTitle="大标题" :hasFooter="hasFooter" :type="'error'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow"> <GLDialog :append-to-body="true" :mode="mode" bigTitle="大标题" :hasFooter="hasFooter" :type="'error'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow">
<div> <div>
<div>这是一段信息</div> <div>这是一段信息</div>
<div>这是一段信息</div> <div>这是一段信息</div>
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
<el-button type="primary" size="small" @click="dialogShow = false">确定123</el-button> <el-button type="primary" size="small" @click="dialogShow = false">确定123</el-button>
</span> --> </span> -->
</GLDialog> </GLDialog>
<GLDialog :mode="mode" title="提示" :hasFooter="hasFooter" :type="'error'" :content="'hello HelloWorld'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow2"></GLDialog> <GLDialog :append-to-body="true" :mode="mode" title="提示中" :hasFooter="hasFooter" :type="'error'" :content="'hello HelloWorld'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow2"></GLDialog>
<GLDialog title="提示123" :mode="mode" :hasFooter="hasFooter" :type="'info'" :content="'hello HelloWorld'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow1"></GLDialog> <GLDialog title="提示123" :mode="mode" :hasFooter="hasFooter" :type="'info'" :content="'hello HelloWorld'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow1"></GLDialog>
<!-- <GLDialog title="提示123" :mode="mode" :hasFooter="hasFooter" :type="'info'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow1"> <!-- <GLDialog title="提示123" :mode="mode" :hasFooter="hasFooter" :type="'info'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow1">
<div>hello</div> <div>hello</div>
......
<template> <template>
<div class="gl-dialog-wrap " :class="mode" :id="idDom"> <div class="gl-dialog-wrap " :class="mode" :id="idDom" >
<el-dialog v-bind="$attrs" v-on="$listeners"> <el-dialog v-bind="$attrs" v-on="$listeners">
<template v-slot:title> <template v-slot:title>
<!-- 标题插槽 --> <!-- 标题插槽 -->
...@@ -88,6 +88,11 @@ export default { ...@@ -88,6 +88,11 @@ export default {
type: String, type: String,
// `success` / `info` / `warning` / `error` // `success` / `info` / `warning` / `error`
default: '' default: ''
},
// 是否添加到body
appendToBody:{
type: Boolean,
default: false
} }
}, },
data() { data() {
...@@ -100,6 +105,9 @@ export default { ...@@ -100,6 +105,9 @@ export default {
document.addEventListener('keyup', (e)=>{ document.addEventListener('keyup', (e)=>{
this.keyupHook(e) this.keyupHook(e)
}); });
if (this.appendToBody) {
document.body.appendChild(this.$el);
}
}, },
computed: { computed: {
okName: function() { okName: function() {
...@@ -204,6 +212,9 @@ export default { ...@@ -204,6 +212,9 @@ export default {
document.removeEventListener('keyup',(e)=>{ document.removeEventListener('keyup',(e)=>{
this.keyupHook(e) this.keyupHook(e)
}) })
if (this.appendToBody && this.$el && this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el);
}
} }
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!