撸码客
撸码客
  • 发布:2020-09-15 14:25
  • 更新:2020-09-15 15:49
  • 阅读:633

自定义组件引用的时候组件对象不可以使用变量吗?

分类:uni-app

如题,用uniapp开发微信小程序的时候,引用自定义组件的时候,如果把组件配置对象单独拿出来的话,组件渲染就失败了。
export default {
components:{
"foot-bar":footBar
},
...
}

以上是标准的组件引用方式,可以正常使用,但是我把{ "foot-bar":footBar }对象部分单独拿出来就会出错,如:

const componentObj={
"foot-bar":footBar
}

export default {
components:componentObj,
...
}

请问是什么原因?

2020-09-15 14:25 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

编译至小程序平台,需要静态扫描注册的组件,目前仅扫描固定格式的组件注册方式,建议使用easycom:https://uniapp.dcloud.net.cn/collocation/pages?id=easycom

  • 撸码客 (作者)

    多谢

    2020-09-15 16:36

  • 遇见最好

    这个自动导入的组件配置,我在使用 list-indexed 时,出现引入错误。


    list-indexed 的组件中,存在list-indexed-item


    使用 list-indexed-item 根据自动导入配置则将 list-indexed-item 的引入路径识别为 @dcloude/ui/components/list-indexed-item/list-indexed-item.vue 但是实际上,list-indexed-item.vue 这个组件是在 components/list-indexed/ 的目录下

    2020-09-18 13:37

  • 遇见最好

    目前的方式在 easycom 中进行 list-indexed-item 的单独配置,并在 对应的自动匹配规则前面即可。

    2020-09-18 13:39

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