vue 如何在iframe中显示一个全屏的弹窗

<script type="text/html" id="openPayPopup">
    <div id="open-pay-popup" class="open-pay-popup-pop">
        <div class="header">
            <span>选择支付</span> 
            <span @click="close"></span>    
        </div>
        <div class="center">
            <div class="form-item">
                <label>支付类型:</label>
                <div>
                    <input type="radio"  value="0" id="pay1"/>
                    <label for="pay1">支付宝</label>
                    <input type="radio"  value="1" id="pay2"/>
                    <label for="pay2">微信</label>
                </div>    
            </div>
        </div>
        <div>
            <span class="confirm-btn" @click="submit">确定</span>
            <span class="cancel-btn" @click="close">取消</span>
        </div>
    </div>
</script>

 

将组件挂载到body中 

var OpenScanPayPopup = Vue.extend({
        template: "#openPayPopup",
        data: function () {
            return {
                info: null
            }
        }
})


var vm = new Vue({
    data: function () {
        return {
            scanPayStatusInfo: {}
        }
    },
    created: function () {
        var oOpenScanPayPopup = new OpenScanPayPopup();
        oOpenScanPayPopup.info = this.scanPayStatusInfo;
top.document.getElementsByTagName('body')[0].appendChild(oOpenScanPayPopup.$mount().$el);   
    }
})

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
A: 首先,需要在Vue项目安装ElementUI组件库,用于实现弹窗的样式。 安装ElementUI: ``` npm i element-plus -S ``` 创建一个全屏弹窗组件FullScreenDialog.vue,代码如下: ```html <template> <div class="full-screen-dialog-mask" v-show="visible"> <div class="full-screen-dialog"> <div class="full-screen-dialog-header"> <span>{{ title }}</span> <i class="el-icon-close" @click="close"></i> </div> <div class="full-screen-dialog-body"> <slot></slot> </div> </div> </div> </template> <script> import { reactive } from 'vue'; export default { name: 'FullScreenDialog', props: { visible: { type: Boolean, default: false, }, title: { type: String, default: '全屏弹窗', }, }, setup(props, { emit }) { const state = reactive({}); const close = () => { emit('update:visible', false); }; return { state, close, }; }, }; </script> <style> .full-screen-dialog-mask { position: fixed; top: 0; left: 0; z-index: 1000; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); } .full-screen-dialog { position: absolute; top: 50%; left: 50%; z-index: 1001; width: 80%; max-height: 90%; transform: translate(-50%, -50%); background-color: #fff; border-radius: 5px; overflow: auto; } .full-screen-dialog-header { display: flex; justify-content: space-between; padding: 10px; border-bottom: 1px solid #ebeef5; } .full-screen-dialog-header span { font-size: 16px; } .full-screen-dialog-body { padding: 20px; } </style> ``` 然后,可以在需要使用全屏弹窗的组件引入并使用FullScreenDialog组件,代码如下: ```html <template> <div> <el-button type="primary" @click="dialogVisible = true">打开全屏弹窗</el-button> <full-screen-dialog title="全屏弹窗" v-model:visible="dialogVisible"> <div>这是全屏弹窗的内容</div> </full-screen-dialog> </div> </template> <script> import FullScreenDialog from '@/components/FullScreenDialog.vue'; export default { components: { FullScreenDialog, }, data() { return { dialogVisible: false, }; }, }; </script> ``` 这样就实现一个简单的全屏弹窗组件,用户点击打开按钮时,会弹出全屏弹窗,点击关闭按钮或者遮罩层时,会关闭弹窗

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值