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

在自定义组件中引用 npm 原生第三方组件 #2926

Closed
kennylbj opened this issue Apr 30, 2019 · 6 comments
Closed

在自定义组件中引用 npm 原生第三方组件 #2926

kennylbj opened this issue Apr 30, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@kennylbj
Copy link

kennylbj commented Apr 30, 2019

使用f2-canvas中遇到了问题。

我自定义了一个f2Canvas组件,引用封装了第三方f2-canvas,按照文档编写如下:

// components/f2Canvas

// index.js
Component({
  properties: {
    opts: Object,
  },
});

// index.json
{
  "component": true,
  "usingComponents": {
    // 发现此处无法引用第三方f2-canvas
    "ff-canvas": "@antv/f2-canvas"
  }
}

// index.wxml
<ff-canvas id="column-dom" canvas-id="column" opts="{{ opts }}"></ff-canvas>

在Page中引用该自定义组件时候,报错:

// pages/result/index.js
class Result extends Component {
  config = {
    usingComponents: {
      'f2-canvas': '../../components/f2Canvas/index',
    },
  }
  render () {
    const opts = {
      onInit: this.initChart,
    };
    return (
      <View className='page'>
        <View className='doc-body bg'>
          <View className='panel'>
            <f2-canvas opts={opts} />
          </View>
        </View>
      </View>
    )
  }
}

Component is not found in path "components/f2Canvas/@antv/f2-canvas" (using by "components/f2Canvas/index");onAppRoute Error: Component is not found in path "components/f2Canvas/@antv/f2-canvas" (using by "components/f2Canvas/index")

查看了dist/npm,发现没有@antv/f2-canvas目录。

请问如何在自定义组件中引用第三方的原生组件(需要通过npm安装的原生组件)?还是我的用法有问题,谢谢了。

@taro-bot
Copy link

taro-bot bot commented Apr 30, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@Garfield550
Copy link
Collaborator

暂不支持 npm 方式引入原生组件

image

我自己是用 clone 到本地的形式做的

@kennylbj
Copy link
Author

@Garfield550 很蓝瘦,希望早点支持。😖

@Chen-jj Chen-jj changed the title 在自定义组件中引用原生第三方组件 在自定义组件中引用 npm 原生第三方组件 Apr 30, 2019
@Chen-jj Chen-jj added the enhancement New feature or request label Apr 30, 2019
@cloudZQY
Copy link
Contributor

cloudZQY commented Sep 4, 2019

还是希望能支持直接引用npm第三方原生组件。因为我们团队是从wepy迁移过来的,有些业务类的组件希望能兼容,所以使用原生开发。只能用拷贝的形式的话,会很影响各团队对组件的同步。

@shenghanqin
Copy link
Collaborator

@kennylbj 试试看最新版?或者看看Changelog?

@Chen-jj Chen-jj closed this as completed Jul 10, 2020
@guxinyan
Copy link

guxinyan commented Nov 9, 2020

这个现在在taro3中支持了吗

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

6 participants