uni-app subNVue 原生子窗体简单使用案例(app提交按钮)

时间:2021-6-5 作者:qvyue

因为原生的地图map、video等层级较高,其他的组件无法正常显示,所以使用弹出层用到原生子窗体subNvue
效果如下:

uni-app subNVue 原生子窗体简单使用案例(app提交按钮)
image.png
uni-app subNVue 原生子窗体简单使用案例(app提交按钮)
image.png

用法:
1、在需要使用的页面(addSamplePage)下新建subNvue文件夹,然后在里面建立相应的文件nvue

uni-app subNVue 原生子窗体简单使用案例(app提交按钮)
image.png

2、在pages.json中定义,把样式什么的直接写在需要引用的页面中,例如写在index页面里

{
            "path": "pages/addSamplePage/addSamplePage",
            "style": {
                "navigationBarTitleText": "样品检测新增页",
                "app-plus": {
                    "subNVues": [
                        {
                            "id": "video_mask",
                            "path": "pages/addSamplePage/subnvue/top",
                            "style": {
                                "position": "absolute",
                                "bottom": "0",
                                "left": "0",
                                "width": "100%",
                                "height": "90px",
                                "background": "transparent"
                            }
                        }
                    ]
                }

            }
        }

3.top.nvue页面

保存提交
export default { data() { return { } }, created() { }, beforeDestroy() { }, methods: { submit(e) { uni.$emit('drawer-page', e); }, } } .wrapper { position: relative; flex: 1; justify-content: center; align-items: center; background-color: #fff; border-color: #eee; border-style: solid; border-width: 4px; } .list { position: absolute; width: 640rpx; height: 90px; flex-direction: row; justify-content: space-between; align-items: center; } .text { height: 50px; color: #fff; background-color: #192c7c; width: 275rpx; text-align: center; line-height: 50px; border-radius: 25px; font-size: 30upx; }

4.在addSamplePage.vue页面中使用方法


    export default {
        data() {
            return {};
        },

        onLoad() {
            // #ifdef APP-PLUS
            this.playVideo()
            uni.$on('drawer-page', (data) => {
                uni.showToast({
                    title: '点击了第' + data + '项',
                    icon: "none"
                });
            })
            // #endif
        },
        onUnload() {
            uni.$off('drawer-page')
        },
        methods: {
            playVideo() {
                let subNVue = uni.getSubNVueById('video_mask')
                subNVue.show()
            }
        }
    }

需要注意的是nvue文件中很多css都不支持,文字必须写在text内

声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:qvyue@qq.com 进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。