开头先放一些需要大概了解的官方文档链接地址

  https://uniapp.dcloud.io/use-weex

  https://uniapp.dcloud.io/api/window/subNVues

  https://weex.apache.org/zh/docs/api/weex-variable.html

 

1、新建一个 uni-app 项目(使用 Hbuilder X)

uni-app subNVue 原生子窗体简单使用案例(app端)

 

2、项目结构如下( 在  pages 目录下的 index 目录中,新建一个 subNVue 目录,在此目录中新建一个 hello.nvue 的文件 )

uni-app subNVue 原生子窗体简单使用案例(app端)

3、hello.nvue 内容如下:

<template>
    <div>
        <text class="hello">{{ content }}</text>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                // 父窗体传递过来的内容
                content: ''
            }
        },
        created() {
            const vm = this;
            // 接收信息的页面
            uni.$on('page-popup', (data) => {
                switch( data.type ){
                    case 'one':
                        vm.content = data.content;
                    break;
                    case 'two':
                        vm.content = data.content;
                    break;
                    // .... 
                }
            });
        },
        beforeDestroy() {
            
        },
        methods: {

        }
    }
</script>

<style>
    .hello {
        font-size: 30px;
        color: red;
    }
</style>
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2021-11-26
  • 2021-07-19
  • 2021-04-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-08
  • 2021-07-06
  • 2022-03-02
  • 2021-07-26
  • 2021-11-19
  • 2022-12-23
相关资源
相似解决方案