W小姐
W小姐
  • 发布:2019-06-17 14:41
  • 更新:2019-06-17 15:05
  • 阅读:1305

正式版2.0.1中,subNVue为null,官方helloapp可以正常运行

分类:uni-app

根据官方提供的文档,在alpha版本中写的demo,能正常运行,后来正式版更新到2.0.0,更新文档中说明支持subNVue,然后我就把demo直接拿到正式版2.0.0中运行,发现报错,后正式版更新到2.0.1,依然报错,官方的hello实例却可以正常运行,求大神们帮我看看
错误msg:
14:34:06.723 thirdScriptError
14:34:06.744 Cannot read property 'show' of null; [Component] Event Handler Error @ pages/index/index#bound handleProxy
14:34:06.763 TypeError: Cannot read property 'show' of null
14:34:06.783 at Vue$3.open (uni-app:///pages/index/index.vue?vue&type=script&lang=js&?d225:139:15)
14:34:06.803 at Array.boundFn (G:/%E5%AE%89%E8%A3%85%E5%8C%85/HBuilderX.1.4.0.20181227.full/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/mpvue/index.js:249:63)
14:34:06.823 at Vue$3.handleProxyWithVue [as $handleProxyWithVue] (G:/%E5%AE%89%E8%A3%85%E5%8C%85/HBuilderX.1.4.0.20181227.full/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/mpvue/index.js:5554:40)
14:34:06.844 at r.handleProxy (G:/%E5%AE%89%E8%A3%85%E5%8C%85/HBuilderX.1.4.0.20181227.full/HBuilderX/plugins/uniapp-cli/node_modules/@dcloudio/vue-cli-plugin-uni/packages/mpvue-page-factory/index.js:77:24)

2019-06-17 14:41 负责人:无 分享
已邀请:
DCloud_Android_ST

DCloud_Android_ST

对象为空。获取getSubNViewById的时机晚一些试试。

  • W小姐 (作者)

    在@tap中调用方法:

    let subNVue = uni.getSubNVueById('select');

    setTimeout(function(){

    console.log("subNVue--"+subNVue);

    subNVue.show('slide-in-bottom', 300, function() {

    uni.$emit('page-popup', {

    enumCode: enumCode,

    selectValue:_this.selectValue,

    });

    });

    },1000)依然不行

    2019-06-17 15:17

  • W小姐 (作者)

    subNVue--null at pages/index/index.vue:139

    15:15:15.295 thirdScriptError

    15:15:15.315 Cannot read property 'show' of null;at pages/index/index onReady function;at setTimeout callback function

    15:15:15.336 TypeError: Cannot read property 'show' of null

    15:15:15.357 at Function.eval (uni-app:///pages/index/index.vue?vue&type=script&lang=js&?d225:140:17)

    2019-06-17 15:17

  • DCloud_Android_ST

    回复 W小姐:


    setTimeout(function(){

    let subNVue = uni.getSubNVueById('select');


    console.log("subNVue--"+subNVue);


    subNVue.show('slide-in-bottom', 300, function() {


    uni.$emit('page-popup', {


    enumCode: enumCode,


    selectValue:_this.selectValue,


    });


    });


    },1000)

    2019-06-17 15:42

  • W小姐 (作者)

    回复 DCloud_Android_ST: 你的代码我试了,不行

    2019-06-17 16:40

  • DCloud_Android_ST

    回复 W小姐: 那就参考示例从新一写一个试试。

    2019-06-17 16:45

  • W小姐 (作者)

    回复 DCloud_Android_ST: "usingComponents" : true,使用自定义组件模式以后,就正常了,文档里并没有说明,建议添加

    2019-06-17 17:22

该问题目前已经被锁定, 无法添加新回复