陌上华年
陌上华年
  • 发布:2020-04-26 10:43
  • 更新:2020-05-11 17:43
  • 阅读:597

分类:uni-app
2020-04-26 10:43 负责人:无 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

到底你说的是H5还是App,你怎么还写了v3?v3是App的配置。
你在之前版本使用的时候是否正常?

  • 陌上华年 (作者)

    H5...没有正常过~~

    2020-04-27 10:11

  • 1***@qq.com

    回复 陌上华年: 你的问题解决了吗 ?我昨天也遇到,组件是之前写的,之前只有小程序,没有什么问题, 由于变动需要做h5 兼容,出现相同的问题

    2020-05-09 10:41

  • 1***@qq.com

    回复 1***@qq.com: 地址: https://ask.dcloud.net.cn/question/95999

    2020-05-09 11:27

  • 白羽

    我在提交 2.6.10+各版本的text解析‘\n’错误这个bug时,顺带提到了这个问题,即H5端和非H5端引用v-for子组件的方式不兼容。可能是由于没有独立开贴,官方忽略了。


    <template>  
    ...
    <view v-else-if="type === 'root'" class="qiu-root" @touchstart="onRootTouchstart">
    <qiu-holotext v-for="(child, index) in content.value" :content2="child" :key="index" :tid="index" class="root-child"></qiu-holotext>
    </view>
    ...
    </template>

    像这样的模板,要想引用子组件节点,得这么写


        // #ifdef H5  
    rootNode = this.$children[0].$children
    // #endif
    // #ifndef H5
    rootNode = this.$children
    // #endif

    希望官方能将二者打通。最好是将H5的写法改成非H5写法。

    2020-05-09 12:18

1***@qq.com

1***@qq.com

同问怎么解决?

  • 白羽

    建议这样:


        // #ifdef H5    
    rootNode = this.$children[0].$children
    // #endif
    // #ifndef H5
    rootNode = this.$children
    // #endif

    试一试,应该没问题

    2020-05-09 12:23

  • 1***@qq.com

    回复 白羽: 是的 我上午也用了这种方式处理

    2020-05-09 16:21

DCloud_UNI_GSQ

DCloud_UNI_GSQ

已在文档说明:
H5端 viewtext 等内置标签是以 Vue 组件方式实现,$children 会获取这些内置组件

目前提供2种解决方法:

  1. 使用条件编译
  2. 组件根节点用 div

另外,在各端访问$children是为了实现什么功能?

  • 陌上华年 (作者)

    实现类似radio-group和radio的功能~~~判断当前选择的组件

    2020-05-19 17:58

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