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 Next beta4,prerender报错 #6037

Closed
yz1311 opened this issue Apr 18, 2020 · 2 comments
Closed

Taro Next beta4,prerender报错 #6037

yz1311 opened this issue Apr 18, 2020 · 2 comments
Assignees
Milestone

Comments

@yz1311
Copy link

yz1311 commented Apr 18, 2020

问题描述

1.组件的属性值处理有问题,现在只处理string类型,number boolean都会导致报错

https://github.com/NervJS/taro/blob/next/packages/taro-mini-runner/src/prerender/prerender.ts#L28

getAttrValue的参数,boolean和number都有可能

2.不应该处理*.config.ts文件

复现步骤

1.随便写number boolean类型的值都会编译报错(下面属性值随便取的,三种情况任一种都会报错)

<ScrollView aa bb={true} cc={1}> 

</ScrollView>

2.按照下面配置,如果对应的文件夹里面有*.config.ts文件,也会编译并报错

prerender: {
match: 'pages/home/**'
}

期望行为

运行正常

报错信息

1.问题1

⚠️  页面 pages/my/myIndex 预渲染失败:
TypeError: str.charAt is not a function
    at unquote (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:24:21)
    at getAttrValue (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:36:12)
    at /Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:73:36
    at Array.map (<anonymous>)
    at Prerender.buildAttributes (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:73:18)
    at Prerender.renderToXML (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:93:111)
    at Object.base.apply (/Users/zhaoyang/Projects/preplan-taro/node_modules/vm2/lib/contextify.js:620:32)
    at Array.map (<anonymous>)
    at Object.base.apply (/Users/zhaoyang/Projects/preplan-taro/node_modules/vm2/lib/contextify.js:228:34)
    at Prerender.renderToXML (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:93:146)
    at Prerender.<anonymous> (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:161:28)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:5:58)

2.问题2

⚠️  页面 pages/home/homeIndex.config 预渲染失败:
TypeError [Error]: page.onLoad is not a function
    at module.exports (/Users/zhaoyang/Projects/preplan-taro/dist:5:16)
    at Object.base.apply (/Users/zhaoyang/Projects/preplan-taro/node_modules/vm2/lib/contextify.js:228:34)
    at /Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:198:13
    at new Promise (<anonymous>)
    at Prerender.renderToData (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:190:16)
    at Prerender.<anonymous> (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:157:35)
    at Generator.next (<anonymous>)
    at /Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/zhaoyang/Projects/preplan-taro/node_modules/@tarojs/mini-runner/dist/prerender/prerender.js:4:12)

系统信息

Taro CLI 3.0.0-beta.4 environment info:
    System:
      OS: macOS 10.15.2
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.14.1 - /usr/local/bin/node
      Yarn: 1.21.1 - /usr/local/bin/yarn
      npm: 6.13.4 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 3.0.0-beta.4 => 3.0.0-beta.4 
      @tarojs/taro: 3.0.0-beta.4 => 3.0.0-beta.4 
      @tarojs/webpack-runner: 3.0.0-beta.4 => 3.0.0-beta.4 
      eslint-config-taro: 3.0.0-beta.4 => 3.0.0-beta.4 
      react: ^16.10.0 => 16.13.1 
    npmGlobalPackages:
      typescript: 3.7.5

补充信息

能不能static getDerivedStateFromProps()给了例子,或者给个完整的prerender的demo

另外,这种错误时因为什么导致的?

⚠️  页面 pages/home/addPlanShipDynamic 预渲染失败:
Error: 初始化渲染没有任何数据
@taro-bot
Copy link

taro-bot bot commented Apr 18, 2020

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Apr 18, 2020

欢迎提交 Issue~

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

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

Good luck and happy coding~

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