b2nil / taro-ui-vue3

采用 Vue 3.0 重写的 Taro UI 组件库
https://b2nil.github.io/taro-ui-vue3/
MIT License
160 stars 51 forks source link

使用taro-ui-vue3在钉钉小程序报错 #103

Open yyq914828jzg opened 3 years ago

yyq914828jzg commented 3 years ago

app.js中引入 import { createUI } from 'taro-ui-vue3' npm run dev:dd 的时候报错

" '@tarojs/components' does not contain an export named 'OpenData'.

b2nil commented 3 years ago

OpenData 只有 AtAvatar 用到。这个报错影响程序正常运行么?

zjy2931 commented 2 years ago

不影响运行也不应当这样报错 吧

b2nil commented 2 years ago

@zjy2931 @yyq914828jzg

其他没有 OpenData 组件的小程序平台使用时会报错,是因为 AtAvatar@tarojs/components 中明确引用了 OpenData 组件:

import { Image, OpenData, Text, View } from '@tarojs/components'

两个办法:

  1. 如果不使用 AtAvatar 组件,不要引用就行了。请按需引用其他组件。
    // 这样会引用全部组件,包括 AtAvatar。
    import { createUI } from 'taro-ui-vue3'
    const tuv3 = createUI()
    ...
    App.use(tuv3)
  2. 如果要使用 AtAvatar 组件,请自行修改。
    • 不要从 @tarojs/components 引用 OpenData
    • 使用 vueresolveComponent 函数来解析 OpenData 组件
      const children = isWEAPP && props.openData && props.openData.type === 'userAvatarUrl'
          ? h(resolveComponent('open-data'), { type: props.openData.type })
          : props.image
              ? h(Image, { class: 'at-avatar__img', src: props.image })
              : h(Text, { class: 'at-avatar__text' }, { default: () => letter.value })