Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何引入小程序自定义组件? #288

Closed
TooBug opened this issue Jul 8, 2018 · 6 comments
Closed

请问如何引入小程序自定义组件? #288

TooBug opened this issue Jul 8, 2018 · 6 comments
Labels
enhancement New feature or request

Comments

@TooBug
Copy link

TooBug commented Jul 8, 2018

小程序已经支持了自定义组件,taro是否支持引入已经写好的自定义组件?如果支持的话要如何引入。

我尝试在页面中使用import引入,会报错误

编译  组件文件  src/pages/components/wemark/wemark
{ Error: ENOENT: no such file or directory, open '/wemark/taro/src/pages/components/wemark/wemark'
    at Object.fs.openSync (fs.js:663:18)
    at Object.fs.readFileSync (fs.js:568:33)
    at buildSingleComponent (/wemark/taro/node_modules/@tarojs/cli/src/weapp.js:879:31)
    at Promise.all.componentPathList.map.componentPath (/wemark/taro/node_modules/@tarojs/cli/src/weapp.js:854:61)
    at Array.map (<anonymous>)
    at buildDepComponents (/wemark/taro/node_modules/@tarojs/cli/src/weapp.js:854:40)
    at buildSinglePage (/wemark/taro/node_modules/@tarojs/cli/src/weapp.js:752:40)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/wemark/taro/src/pages/components/wemark/wemark' }

尝试使用小程序的页面配置usingComponents,发现taro并不会将组件代码复制到dist目录。

@yuche
Copy link
Contributor

yuche commented Jul 8, 2018

遗憾的是我们现在还不支持从 NPM 引入自定义组件,计划专门做一个命令打包发布到 NPM 组件。

@yuche yuche added the enhancement New feature or request label Jul 8, 2018
@TooBug
Copy link
Author

TooBug commented Jul 9, 2018

不需要从npm包,我拷文件进去也可以接受。就是微信小程序的自定义组件,是否支持在taro中直接引用呢?

@luckyadam
Copy link
Member

@TooBug 目前来说还不行,组件化这块正在用微信的自定义组件来重构~ 重构完成后就可以,预计本周有重构的 beta 版本~

@TooBug
Copy link
Author

TooBug commented Jul 9, 2018

好的,期待……

@shenqihui
Copy link

战略性关注

@luckyadam
Copy link
Member

luckyadam commented Aug 6, 2018

最新的 beta 版本,已经支持了
https://nervjs.github.io/taro/docs/mini-third-party

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants