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

微信小程序编译报错 #3092

Closed
ctcx opened this issue May 18, 2019 · 2 comments
Closed

微信小程序编译报错 #3092

ctcx opened this issue May 18, 2019 · 2 comments
Assignees

Comments

@ctcx
Copy link

ctcx commented May 18, 2019

主要有两个错误,目前已经找到原因。
错误一:组件XXX路径错误,请检查!(可能原因是导出的组件名不正确)
报这个错是因为我组件直接导出的是匿名函数,如:
export default ({ title }) => <View>{title}</View>
改为传统方式就没问题了,如:
`export default class XXX extends Component {

render(){
const { title } = this.props;
return ({title})
}`

错误二:TypeError: unknown: Cannot read property 'name' of null
{ TypeError: unknown: Cannot read property 'name' of null at ClassDeclaration (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.1.2.26@eslint-plugin-taro/rules/class-naming.js:60:77) at listeners.(anonymous function).forEach.listener (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.4.19.1@eslint/lib/util/safe-emitter.js:47:58) at Array.forEach (<anonymous>) at Object.emit (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.4.19.1@eslint/lib/util/safe-emitter.js:47:38) at NodeEventGenerator.applySelector (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.4.19.1@eslint/lib/util/node-event-generator.js:251:26) at NodeEventGenerator.applySelectors (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.4.19.1@eslint/lib/util/node-event-generator.js:280:22) at NodeEventGenerator.enterNode (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.4.19.1@eslint/lib/util/node-event-generator.js:294:14) at CodePathAnalyzer.enterNode (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.4.19.1@eslint/lib/code-path-analysis/code-path-analyzer.js:608:23) at Traverser.enter [as _enter] (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.4.19.1@eslint/lib/linter.js:865:28) at Traverser._traverse (/usr/local/lib/node_modules/.@tarojs/cli_npminstall/node_modules/.4.19.1@eslint/lib/util/traverser.js:132:14) _babel: true }

这是因为我导出的匿名对象,如:
export default class extends Component {
我改为
export default class XXX extends Component {
就没问题了。

之前用 react 时习惯了,导出没有状态的组件 和 导出匿名对象;为什么taro不支持呢?

@taro-bot
Copy link

taro-bot bot commented May 18, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@taro-bot
Copy link

taro-bot bot commented May 18, 2019

CC @yuche

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