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

关于引入第三方组件问题 #1035

Closed
9188 opened this issue Mar 5, 2018 · 6 comments
Closed

关于引入第三方组件问题 #1035

9188 opened this issue Mar 5, 2018 · 6 comments
Labels
inactive Inactive issue, will be auto closed in 7 days

Comments

@9188
Copy link

9188 commented Mar 5, 2018

类似 wepy-com-toast 包, 是一个npm包中只包含一个组件,
请问一个npm里面有多个组件的形式支持吗?

比如我的包cy 目录如下

├── button.wpy
├── toast.wpy
├── package.json

import button from 'cy/button'
import button from 'cy/toast'

mac上没问题
window 上面依然报错 说找不到 'cy/button'

@Gcaufy
Copy link
Collaborator

Gcaufy commented Mar 5, 2018

理论上是可以的。。具体是哪个库。我去测试一下看看。

@9188
Copy link
Author

9188 commented Mar 5, 2018

@Gcaufy

可以用下面这个库试试

npm i cyw --save
<loadings />

import loadings from 'cyw/Loading'

this.$invoke('loadings', 'show')
this.$invoke('loadings', 'hide')

@idseventeen
Copy link

同问,也卡在这个地方了

@idseventeen
Copy link

idseventeen commented Mar 19, 2018

看了你的组件库目录结构,按照vue的组件开发思路,不是应该有个index.js文件里导出么?例如:

// index.js 组件导出文件

import Button from 'path/to/button'
import Dialog from 'path/to/dialog'
export {
  Button,
  Dialog
}

使用方式:

// page.wpy

<template>
  <Button></Button>
</template>

<script>
import wepy from 'wepy'
import { Button } from 'path/to/uikit'

export default class Page extends wepy.page {
  commponets = {
    Button
  }
}
</script>

我遇到的问题是

这样引入第三方组件,执行 wepy build 组件库的代码并未编译,仅将 index.js 文件拷贝至 dist/npm/{uikit} 目录下

截图

组件库目录结构

编译后dist/npm下的组件库目录结构

编译后的index.js文件

@Gcaufy 还望抽空能帮忙解答一下,谢谢!

@HEYEggplant
Copy link

请问你的问题解决了吗 我自己的多项目共用模块 也是这个问题找不到文件

@stale
Copy link

stale bot commented Jun 12, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
因为这个 Issue 最近没有任何有效回复,所以被自动标记为了stale。 如果在未来7天依旧没有任何激活操作,那么该 Issue 将会被自动关闭。 感谢您的提问。

@stale stale bot added the inactive Inactive issue, will be auto closed in 7 days label Jun 12, 2018
@stale stale bot closed this as completed Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive issue, will be auto closed in 7 days
Projects
None yet
Development

No branches or pull requests

4 participants