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

[taro-2.0.0]使用taro init 的默认项目,在npm run dev:swan 情况下,修改src/pages/index/index.jsx 任意内容多次后报错 #5293

Closed
zerob13 opened this issue Jan 10, 2020 · 5 comments
Assignees

Comments

@zerob13
Copy link

zerob13 commented Jan 10, 2020

问题描述

百度小程序的转译的过程中,多次修改页面组件后,会导致生产出来的 *.json 文件中,多了一个
"component":true的字段,从而导致百度小程序开发平台把页面当作自定义组件处理最终报错

复现步骤

  1. 使用 taro init 创建一个测试项目
  2. 在项目目录中执行 npm run dev:swan 进行百度小程序的开发
  3. 打开百度小程序开发工具,导入该项目,此时会编译运行成功,查看dist/pages/index/index.json
    可以看到内容是:
{"usingComponents":{},"navigationBarTitleText":"首页"}
  1. 修改 src/pages/index/index.jsx render 函数中任意内容,并保存
  2. 此时会触发taro重新编译,等编译成功后查看百度小程序开发工具
  3. 重复4-5后,百度小程序开发工具会报错,此时查看dist/pages/index/index.json 内容为:
{"component":true,"usingComponents":{},"navigationBarTitleText":"首页"}

期望行为

"component":true 不应该在页面组件中出现

报错信息

customComponentStatistics error: TypeError: Cannot read property 'componentProto' of undefined
【Custom Component Error】can't find pages/index/index, please check your config:
            1. Please check if the reference path is correct;
            2. If it is a page under this path, the "component: true" in the current page JSON should be removed.

系统信息

👽 Taro v2.0.0


  Taro CLI 2.0.0 environment info:
    System:
      OS: macOS 10.15.2
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
      npm: 6.13.4 - ~/.nvm/versions/node/v12.13.0/bin/npm
    npmPackages:
      @tarojs/cli: 2.0.0 => 2.0.0
      @tarojs/components: 2.0.0 => 2.0.0
      @tarojs/components-qa: 2.0.0 => 2.0.0
      @tarojs/mini-runner: 2.0.0 => 2.0.0
      @tarojs/redux: 2.0.0 => 2.0.0
      @tarojs/router: 2.0.0 => 2.0.0
      @tarojs/taro: 2.0.0 => 2.0.0
      @tarojs/taro-alipay: 2.0.0 => 2.0.0
      @tarojs/taro-h5: 2.0.0 => 2.0.0
      @tarojs/taro-qq: 2.0.0 => 2.0.0
      @tarojs/taro-quickapp: 2.0.0 => 2.0.0
      @tarojs/taro-rn: 2.0.0 => 2.0.0
      @tarojs/taro-swan: 2.0.0 => 2.0.0
      @tarojs/taro-tt: 2.0.0 => 2.0.0
      @tarojs/taro-weapp: 2.0.0 => 2.0.0
      @tarojs/webpack-runner: 2.0.0 => 2.0.0
      eslint-config-taro: 2.0.0 => 2.0.0
      eslint-plugin-taro: 2.0.0 => 2.0.0
      nerv-devtools: ^1.5.6 => 1.5.6
      nervjs: ^1.5.6 => 1.5.6
      stylelint-config-taro-rn: 2.0.0 => 2.0.0
      stylelint-taro-rn: 2.0.0 => 2.0.0

补充信息

如果您有功能上的建议,可以提到 FeatHub

使用上的问题,欢迎在「Taro 社区」一起交流

@taro-bot
Copy link

taro-bot bot commented Jan 10, 2020

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Jan 10, 2020

欢迎提交 Issue~

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

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

Good luck and happy coding~

@zerob13
Copy link
Author

zerob13 commented Jan 10, 2020

附加一个信息,该bug必须修改文件多次后才能产生,最少两次,第一次修改不会存在

@shenghanqin shenghanqin changed the title 使用taro init 的默认项目,在npm run dev:swan 情况下,修改src/pages/index/index.jsx 任意内容多次后报错 [taro-2.0.0]使用taro init 的默认项目,在npm run dev:swan 情况下,修改src/pages/index/index.jsx 任意内容多次后报错 Jan 12, 2020
@taro-bot
Copy link

taro-bot bot commented Jan 13, 2020

CC @luckyadam

@heart-er
Copy link

heart-er commented Aug 6, 2020

将组件放在pages外部的componets中,同样复现了该问题

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

4 participants