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

自定义组件统一用index.js输出是编译报错 #347

Closed
chm1n9 opened this issue Jul 18, 2018 · 3 comments
Closed

自定义组件统一用index.js输出是编译报错 #347

chm1n9 opened this issue Jul 18, 2018 · 3 comments

Comments

@chm1n9
Copy link

chm1n9 commented Jul 18, 2018

问题描述
在components中用文件夹定义了一些组件,然后在components/index.js中统一输出,引用报错

复现步骤
components/结构
|--com1/
|--com2/
|--...
|--index.js
每个组件文件夹里面有index.js, index.scss。js直接引用scss

// components/index.js
export { default as Filter } from './filter'
export { default as Room } from './room'
export { default as DSlider } from './dSlider'
export { default as Loading } from './loading'

// pages/index/index.js
import { Room, Loading, Filter } from '../../components/index'
// import Room from '../../components/room'
// import Loading from '../../components/loading'
// import Filter from '../../components/filter'

用/components/index引用会报错,dist里面 pages/index不能生成index.wxss

期望行为
希望可以统一输出

报错信息
编译 组件文件 src/components/index.js
TypeError: Cannot read property 'scope' of undefined
at transform (E:\workspace-mine\zhunar\node_modules@tarojs\transformer-wx\lib\src\index.js:167:36)
at buildSingleComponent (E:\workspace-mine\zhunar\node_modules@tarojs\cli\src\weapp.js:884:29)
at Promise.all.componentPathList.map.componentPath (E:\workspace-mine\zhunar\node_modules@tarojs\cli\src\weapp.js:854:61)
at Array.map ()
at buildDepComponents (E:\workspace-mine\zhunar\node_modules@tarojs\cli\src\weapp.js:854:40)
at buildSinglePage (E:\workspace-mine\zhunar\node_modules@tarojs\cli\src\weapp.js:752:40)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
生成 页面WXSS dist/pages/index/index.wxss
TypeError: Cannot read property 'wxss' of undefined
at buildDepComponentsResult.map.item (E:\workspace-mine\zhunar\node_modules@tarojs\cli\src\weapp.js:861:23)
at Array.map ()
at getDepStyleList (E:\workspace-mine\zhunar\node_modules@tarojs\cli\src\weapp.js:860:44)
at buildSinglePage (E:\workspace-mine\zhunar\node_modules@tarojs\cli\src\weapp.js:761:28)
at
at process._tickCallback (internal/process/next_tick.js:188:7)

系统信息

  • 操作系统: Windows 10
  • Taro 版本 v.0.0.69
  • Node.js 版本 v8.9.0

补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

@super918180
Copy link

我也遇到同样的问题了

@luckyadam
Copy link
Member

暂时不支持这样统一暴露,直接引用吧~

@luckyadam
Copy link
Member

最新的 beta 版本已经支持这样输出组件了

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

No branches or pull requests

3 participants