We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
微信小程序
https://gitee.com/Jackie-Wu/taro-vue3-prerender-error 小程序基础库: 1.06.2209190 使用框架: Vue 3
打开示例可以看到 vue3在配置了 prerender后编译时会报错 我打印 了这段代码 位置 https://github.com/NervJS/taro/blob/next/packages/taro-webpack5-runner/src/prerender/prerender.ts
renderToData({ path, params }) { console.log(path, params); return new Promise((resolve, reject) => { const dataReceiver = this.vm.run(` const page = require('${this.getRealPath(path)}') page.route = '${path}' module.exports = function (cb) { page.onLoad(${JSON.stringify(params || {})}, cb) } `, this.outputPath); dataReceiver((data) => { console.log(data, 'data') const domTree = data['root.cn.[0]'] || data['root.cn[0]']; if (domTree == null) { reject(new Error('初始化渲染没有任何数据。')); } resolve(domTree); }); }); }
发现在 vue3 里 输出的结果是
[Object: null prototype] { 'root.cn': [ { nn: '5', sid: '_AM', option: {}, cn: [Array] }, '0': { nn: '5', sid: '_AM', option: {}, cn: [Array] } ], 'root.uid': 'pages/gift/index?$taroTimestamp=1665221258333', 'root.cl': '' }
这段的取参方式导致无法拿到对应模板数据
const domTree = data['root.cn.[0]'] || data['root.cn[0]'];
而我使用 data['root.cn'][0] 的参数是可以拿到数据的 但是 模板渲染就会有问题 标签显示错误
data['root.cn'][0]
<import src="../../base.wxml"/> <block wx:if="{{root.uid}}"> <template is="taro_tmpl" data="{{root:root}}" /> </block> <block wx:else> <5 id="_AM" option='{}' ><8 ></8></5> </block>
这个是dist打印出来的模板 标签是错误的
正常编译
取参错误,编译后模板错误
Taro CLI 3.5.6 environment info: System: OS: macOS 11.6.8 Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.2 - ~/.tnvm/versions/alinode/v7.4.0/bin/node Yarn: 1.22.17 - ~/.tnvm/versions/alinode/v7.4.0/bin/yarn npm: 8.1.2 - ~/.tnvm/versions/alinode/v7.4.0/bin/npm npmPackages: @tarojs/cli: 3.5.6 => 3.5.6 @tarojs/components: 3.5.6 => 3.5.6 @tarojs/helper: 3.5.6 => 3.5.6 @tarojs/plugin-framework-vue3: 3.5.6 => 3.5.6 @tarojs/plugin-platform-alipay: 3.5.6 => 3.5.6 @tarojs/plugin-platform-jd: 3.5.6 => 3.5.6 @tarojs/plugin-platform-qq: 3.5.6 => 3.5.6 @tarojs/plugin-platform-swan: 3.5.6 => 3.5.6 @tarojs/plugin-platform-tt: 3.5.6 => 3.5.6 @tarojs/plugin-platform-weapp: 3.5.6 => 3.5.6 @tarojs/router: 3.5.6 => 3.5.6 @tarojs/runtime: 3.5.6 => 3.5.6 @tarojs/shared: 3.5.6 => 3.5.6 @tarojs/taro: 3.5.6 => 3.5.6 @tarojs/taro-h5: 3.5.6 => 3.5.6 @tarojs/webpack5-runner: 3.5.6 => 3.5.6 babel-preset-taro: 3.5.6 => 3.5.6 eslint-config-taro: 3.5.6 => 3.5.6
The text was updated successfully, but these errors were encountered:
fix(webpack5): 修复 prerender 报错,fix #12622
959072e
fix(webpack5): 修复 prerender 报错,fix #12622 (#12670)
ba39234
* fix(webpack5): 修复 prerender 报错,fix #12622 * Update prerender.ts Co-authored-by: Zakary <zakarycode@gmail.com>
Chen-jj
Successfully merging a pull request may close this issue.
相关平台
微信小程序
复现仓库
https://gitee.com/Jackie-Wu/taro-vue3-prerender-error
小程序基础库: 1.06.2209190
使用框架: Vue 3
复现步骤
打开示例可以看到 vue3在配置了 prerender后编译时会报错
我打印 了这段代码 位置 https://github.com/NervJS/taro/blob/next/packages/taro-webpack5-runner/src/prerender/prerender.ts
发现在 vue3 里 输出的结果是
这段的取参方式导致无法拿到对应模板数据
而我使用
data['root.cn'][0]
的参数是可以拿到数据的 但是 模板渲染就会有问题 标签显示错误这个是dist打印出来的模板 标签是错误的
期望结果
正常编译
实际结果
取参错误,编译后模板错误
环境信息
The text was updated successfully, but these errors were encountered: