Taro: Taro 1.3 beta 版本测试通告(当前版本:1.3.0-beta.8)

Created on 5 May 2019  ·  167Comments  ·  Source: NervJS/taro

大家好~
在 Taro 项目组以及社区共同努力下,历时半年左右的开发时间,累计超过 1400 余次 Commit 的 Taro v1.3 beta 版本终于横空出世了!

正所谓「宝剑锋从磨砺出,梅花香自苦寒来」,这是 Taro 历经考验最多的一个版本,是 Taro 遇到问题最多的一个版本,但也是 Taro 自诞生以来,包含特性最为丰富的一个版本。曾经,1.3 版本经历过数次延期,遭受过是否难产的质疑,但横跨半年的开发时间,我们只是一直在不断打磨,不断创新,而不是在虚延岁月。我们可能会迟到,但永远不会缺席!

版本特性

Taro v1.3 版本将为大家带来以下重要的特性:

支持快应用开发

从 1.3 开始,Taro 将正式开始支持 快应用 开发,目前已经在 华为/小米 两个支持快应用的手机上进行测试,支持的快应用平台版本为 1010+

目前已经适配的组件与 API 情况如下:

  • 组件库支持:checkbox/radio/image/input/label/progress/slider/switch/view/text/rich-text
  • API 支持:网络请求、路由 API、分享、界面弹窗、震动、本地存储、部分设备等相关 API

具体使用方式请参考 https://nervjs.github.io/taro/docs/quick-app.html

需要注意的是,在 beta 版本中,由于快应用相关组件与 API 支持还不完善,所以建议不要直接使用 beta 版本开发直接开发快应用。

支持 QQ 轻应用开发

从 1.3 开始,Taro 将正式开始支持 QQ 轻应用 开发。

全面支持 JSX 语法和 React Hooks

从 1.3 开始 Taro 支持了更多的 JSX 写法,包括但不限于,支持函数式组件、render 之外书写 JSX 等等,同时,更让人惊喜的是,新的版本带来了 React Hooks 的支持,大家可以通过如下两个例子进行学习使用:

V2EX: https://github.com/NervJS/taro-v2ex-hooks

TodoMVC: https://github.com/NervJS/taro-todomvc-hooks

大幅提高 H5 性能和可用性

在 1.3 版本中,H5 的打包大小得到了进一步优化,同时 H5 端的 API/组件 数量和质量也得到了大幅地增长,让 H5 的转换更令人放心。

同时,H5 对小程序的页面函数钩子如,onPageScroll/onPullDownRefresh/onReachBottom 等,也进行了同步支持,开发者不再需要自己去写平台区分代码来处理了。

Taro doctor 代码诊断

Taro Doctor 就像一个医生一样,可以诊断项目的依赖、设置、结构,以及代码的规范是否存在问题,并尝试给出解决方案
image

多端同步调试

从 1.3 版本开始,项目编译后的结果不再直接放在 dist 目录下,而是会在 dist 目录下创建一个与编译的目标平台名同名的目录,并将结果放在这个目录下,例如编译到微信小程序,最终结果是在 dist/weapp 目录下,这样做的好处是,各个平台使用独立的目录互不影响,从而达到多端同步调试的目的。

1.3.5-beta.5 开始恢复之前的编译操作,文件会直接编译到 config 中配置的 outputRoot 目录下,如果需要多端同时调试,可以修改配置为

outputRoot: `dist/${process.env.TARO_ENV}`

组件传参(props)系统重构

在 1.3 版本中,我们针对小程序端的 props 系统进行了重构,已经不再需要借助原生小程序的 props 来进行组件属性传递,这带来了以下几点好处:

  • props 传递函数可以获取返回值,且函数名不再需要强制使用 on 开头
  • 自定义组件支持 spread properties
  • 各小程序组件生命周期执行获得统一,componentWillReceiveProps 生命周期表现一致

命令行工具(CLI) 重构

在 1.3 版本中,Taro CLI 使用 TypeScript 进行了彻底重构,为今后的插件化扩展,打下坚实基础,同时提供了 Node API 的方式进行调用,方便可持续集成系统进行集成使用。

RN 端抛弃 Expo

众所周知,Expo 并不适用于国内生态环境,在 1.3 版本中,RN 端不再继续使用 Expo,而提供了自己的 SDK 与原生的壳子,方便用户进行扩展。

支持开发小程序插件

从 1.3 版本开始,Taro 支持直接开发微信与支付宝小程序插件,可以从这里获得更多内容 https://nervjs.github.io/taro/docs/miniprogram-plugin.html

支持小程序云开发

Taro 同时加入对了小程序云开发的支持,为小程序云开发提供了初始化模板,并且将小程序云相关的 API 进行了封装,方便开发者进行使用,可以从这里获得更多内容 https://nervjs.github.io/taro/docs/wxcloud.html

以上就是 Taro 1.3 给广大开发者带来的优秀特性,目前 1.3 处于 beta 阶段,欢迎大家进行试用并提供宝贵意见,让我们一起将 Taro 变得更加好用。

如何升级

升级 Taro CLI

直接安装 beta 版本的 CLI

$ npm i -g @tarojs/cli

升级本地依赖

将 taro 相关的依赖版本号统一修改成 1.3.0-beta.8,然后删掉 node_modules,重新安装依赖即可。

1.3 的任何问题,请在本 issue 下进行回复,我们会第一时间跟进处理。

Announcement

Most helpful comment

页面的config是否可以传入functional component?因为react hooks的想法是在未来取代class组件,但是如果设置config的话就必须用class组件。

All 167 comments

欢迎提交 Issue~

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

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

Good luck and happy coding~

支持!!!

666

目前h5,微信 支付宝小程序 都靠 taro, 加油!

Nice!!!

资词

顶!d=====( ̄▽ ̄*)b

支持 Taro

unbelievable

关注,支持!

支持!

Taro 果然宇宙最强奥特曼啊 哈哈~

支持支持,学好React,上手taro

顶一个

赞~

666

强~

666~

Good!

👍

nice

niu

66666

大爱Taro~

赞一个👍

辛苦了

前排围观

666

点赞

厉害,加油

image
更新后mobx用不了

image
更新后mobx用不了

提供一下相关的代码,或者最好可以给一个 demo 吧

init 一个mobx模版的小程序报错未找到入口 app.json 文件,或者文件读取失败,请检查后重新编译。
image

支持一下

顶一下

厉害了

牛逼~

init 一个mobx模版的小程序报错未找到入口 app.json 文件,或者文件读取失败,请检查后重新编译。
image

额,这个版本编译后的代码在 dist/平台名 这样的目录下,你要修改一下项目配置,或者,选择 dist/平台名 目录进行预览

image
H5端预览图片,并没有缩放到合适大小?
image
这是原图

666

希望文档能同步更新下,比如暂不支持在 render() 之外的方法定义 JSX

请问如何打包成QQ小程序?

Taro v1.3.0-beta.0 build H5代码的时候,输入的路径不是当前项目根目录下的dist文件夹下,而是在当前项目的根目录下创建了当前项目完整路径的子文件夹下的dist
image

Taro v1.3.0-beta.0 build H5代码的时候,输入的路径不是当前项目根目录下的dist文件夹下,而是在当前项目的根目录下创建了当前项目完整路径的子文件夹下的dist
image

收到,我们看下

image

引入hooks方法会提示ts问题,方法也会报错

image

引入hooks方法会提示ts问题,方法也会报错

先写匿名函数

666666 嘻嘻

import 'taro-ui/dist/style/index.scss'
直接引用taro-ui的样式文件会报路径错误。
比如当前项目路径是a/b/demo, 控制台会提示Error: ENOENT: no such file or directory, open '/a/b/node_modules/taro-ui/dist/style/index.scss'

我改成下面的方式就好了。
import '../node_modules/taro-ui/dist/style/index.scss'

import 'taro-ui/dist/style/index.scss'
直接引用taro-ui的样式文件会报路径错误。
比如当前项目路径是a/b/demo, 控制台会提示Error: ENOENT: no such file or directory, open '/a/b/node_modules/taro-ui/dist/style/index.scss'

我改成下面的方式就好了。
import '../node_modules/taro-ui/dist/style/index.scss'

收到,我们看下

  • 无法在自定义组件上添加样式
    image
    image
  • 直接添加style属性也不可以
    image

2934 这个问题,有临时解决方案吗?强制安装旧版的 stylelint 也没有用,因为是独立依赖于 .rn_temp 内的 node_modules 的

49CBF3B7-1D86-4F78-87EA-BA461BCDD268

90D92FC5-6FC5-4A86-9439-2D95EE97F403

image

无法触发函数

@buzhun 看这个 #2964

Typescript模板取消了?

  • 无法在自定义组件上添加样式
    image
    image
  • 直接添加style属性也不可以
    image

老版本也不行,需要自己手动定义className的Props。
@wangjq4214

新版本虽然能用hooks了,但是用typescript的话,没有useState等的定义。
image

externalClasses 不好用了 编译出来后class没有被加上!!!!涉及到好几个页面用到希望能尽快回复
image
image
image

编译后运行结果:
image

666,支持,希望越来越强大

666666

后排兜售香烟瓜子等

支持! 国内开源界难得的清流, 满满的诚意 👍

Taro v1.3.0-beta.0 build H5代码的时候,输入的路径不是当前项目根目录下的dist文件夹下,而是在当前项目的根目录下创建了当前项目完整路径的子文件夹下的dist
image

https://github.com/NervJS/taro/commit/81fa286124d400d80c4363ee488ba5239d51e3bc 已经提交 下个版本修复~

支持支持

import 'taro-ui/dist/style/index.scss'
直接引用taro-ui的样式文件会报路径错误。
比如当前项目路径是a/b/demo, 控制台会提示Error: ENOENT: no such file or directory, open '/a/b/node_modules/taro-ui/dist/style/index.scss'
我改成下面的方式就好了。
import '../node_modules/taro-ui/dist/style/index.scss'

收到,我们看下

1.3.0-beta.1 修复了

  • 版本:1.3.0-beta.1
  • 问题:

eslint-plugin-taro 中的 package.json 缺少 constant 目录,导致运行报错

Error: Cannot read config file: /Users/quinlanzhong/.config/yarn/global/node_modules/eslint-plugin-taro/index.js
Error: Cannot find module '../constant'

https://github.com/NervJS/taro/blob/8a88948f0d3f647fbb2040ac606f4ddc74fbe740/packages/eslint-plugin-taro/package.json#L6-L11

  • 版本:1.3.0-beta.1
  • 问题:

eslint-plugin-taro 中的 package.json 缺少 constant 目录,导致运行报错

Error: Cannot read config file: /Users/quinlanzhong/.config/yarn/global/node_modules/eslint-plugin-taro/index.js
Error: Cannot find module '../constant'

https://github.com/NervJS/taro/blob/8a88948f0d3f647fbb2040ac606f4ddc74fbe740/packages/eslint-plugin-taro/package.json#L6-L11

https://github.com/NervJS/taro/commit/6eec83762a2216173ea2ccb89649944d7281e90f

@luckyadam
版本:1.3.0-beta.1
问题:
[email protected]@eslint-plugin-taro/rules/no-spread-in-props.js报错
Error: Cannot find module '../constant'

 const { buildDocsMeta } = require('../utils/utils')
// eslint-disable-next-line camelcase
const { DEFAULT_Components_SET } = require('../constant')

@luckyadam
版本:1.3.0-beta.1
问题:
[email protected]@eslint-plugin-taro/rules/no-spread-in-props.js报错
Error: Cannot find module '../constant'

 const { buildDocsMeta } = require('../utils/utils')
// eslint-disable-next-line camelcase
const { DEFAULT_Components_SET } = require('../constant')

看楼上

@yuche @moonshadow-miao 临时解决方案是把全局安装中的 \node_modules\eslint-plugin-taro\rules\index.js 中第7行注释掉:
// 'no-spread-in-props': require('./no-spread-in-props'),

各小程序组件生命周期执行获得统一,componentWillReceiveProps 生命周期表现一致

这个版本好像依然没有解决这个问题?

2818

2987 rn 端的 toast.js 泄漏

各小程序组件生命周期执行获得统一,componentWillReceiveProps 生命周期表现一致

这个版本好像依然没有解决这个问题?

2818

这个是父子组件同时绑定 redux 带来的问题,正在解决

  • 版本:1.3.0-beta.1
  • 问题:

eslint-plugin-taro 中的 package.json 缺少 constant 目录,导致运行报错

Error: Cannot read config file: /Users/quinlanzhong/.config/yarn/global/node_modules/eslint-plugin-taro/index.js
Error: Cannot find module '../constant'

https://github.com/NervJS/taro/blob/8a88948f0d3f647fbb2040ac606f4ddc74fbe740/packages/eslint-plugin-taro/package.json#L6-L11

6eec837

package.json添加了files依然报一样的错误,跟node版本有关系?

  • 版本:1.3.0-beta.1
  • 问题:

eslint-plugin-taro 中的 package.json 缺少 constant 目录,导致运行报错

Error: Cannot read config file: /Users/quinlanzhong/.config/yarn/global/node_modules/eslint-plugin-taro/index.js
Error: Cannot find module '../constant'

https://github.com/NervJS/taro/blob/8a88948f0d3f647fbb2040ac606f4ddc74fbe740/packages/eslint-plugin-taro/package.json#L6-L11

6eec837

package.json添加了files依然报一样的错误,跟node版本有关系?

添加了你还要复制过去啊。不然你就跟 https://github.com/NervJS/taro/issues/2947#issuecomment-490334645 说的一样,直接注释掉。

  • 版本:1.3.0-beta.1
  • 问题:

eslint-plugin-taro 中的 package.json 缺少 constant 目录,导致运行报错

Error: Cannot read config file: /Users/quinlanzhong/.config/yarn/global/node_modules/eslint-plugin-taro/index.js
Error: Cannot find module '../constant'

https://github.com/NervJS/taro/blob/8a88948f0d3f647fbb2040ac606f4ddc74fbe740/packages/eslint-plugin-taro/package.json#L6-L11

6eec837

package.json添加了files依然报一样的错误,跟node

你需要把github官方master代码 taro/packages/eslint-plugin-taro 下面的 /constant/文件夹拷贝到你本地代码的[email protected]@eslint-plugin-taro包里面

@moonshadow-miao @yuche 谢谢, 你们的方法试过了,但是没能解决问题
image

image
把你图里圈起来的文件注释掉第七行

image
把你图里圈起来的文件注释掉第七行

跟 #2947 (comment) 报错是不一样的

image
把你图里圈起来的文件注释掉第七行

跟 #2947 (comment) 报错是不一样的

那就是你改坏了,直接把仓库的包替换到你本地的包

image
map数组中函数传参数 ,函数不生效,没有打印出来

image
map数组中函数传参数 ,函数不生效,没有打印出来

开一个新 issue,按 issue 的要求填你的代码

@sprout-echo 自定义函数名onClick? 换个函数名试下可以不

@sprout-echo 自定义函数名onClick? 换个函数名试下可以不

和这个没关系,应该匿名函数的问题

跟函数名没关系,换一个还是不能

------------------ 原始邮件 ------------------
发件人: "meiyzeng"notifications@github.com;
发送时间: 2019年5月8日(星期三) 下午4:47
收件人: "NervJS/taro"taro@noreply.github.com;
抄送: "十二月下的猫"775249762@qq.com; "Mention"mention@noreply.github.com;
主题: Re: [NervJS/taro] Taro 1.3 beta 版本测试通告(当前版本:1.3.0-beta.1) (#2947)

@sprout-echo 自定义函数名onClick? 换个函数名试下可以不


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

请问 1.3.0-beta.1 版本中使用 taro init 命令直接生成项目是去除掉了「是否使用 typescript」的选项了吗?

请问 1.3.0-beta.1 版本中使用 taro init 命令直接生成项目是去除掉了「是否使用 typescript」的选项了吗?

看 commit 是已经修复这个问题了,等发布吧

请问 1.3.0-beta.1 版本中使用 taro init 命令直接生成项目是去除掉了「是否使用 typescript」的选项了吗?

看 commit 是已经修复这个问题了,等发布吧

好的,谢谢。

image
把你图里圈起来的文件注释掉第七行

跟 #2947 (comment) 报错是不一样的

那就是你改坏了,直接把仓库的包替换到你本地的包

我这边试了无效呢

image
image
报错Taro is not defind
s

@fangcaiwen 用1.3版本的cli就会出现这样的问题 我试了上面的demo项目todo也是一样问题存在
https://github.com/NervJS/taro-todomvc-hooks/issues

image
map数组中函数传参数 ,函数不生效,没有打印出来

我遇到了类似的问题,临时解决方案是绑定函数的地方用bind,试试看

<View ... onClick={this.onClick.bind(this,index)}> ....

当我升级到 👽 Taro v1.3.0-beta.1时候,全局配置的config有tabBar这个配置的时候无法编译,抛出下面的错误:
🙅 Failed to compile.

multi (webpack)-dev-server/client?http://127.0.0.1:10086 (webpack)/hot/dev-server.js ./.temp/app.js

全局的config信息如下:
config = {
pages: ['pages/index/index', 'pages/page/index'],
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black'
},
tabBar: {
color: '#8E8E8E',
selectedColor: '#4379FE',
backgroundColor: '#ffffff',
borderStyle: 'black',
list: [
{
pagePath: 'pages/index/index',
text: '服务',
iconPath: './images/icon_menu_service_n.png',
selectedIconPath: './images/icon_menu_service_d.png'
},
{
pagePath: 'pages/page/index',
text: '方案',
iconPath: './images/icon_menu_programme_n.png',
selectedIconPath: './images/icon_menu_programme_d.png'
}
]
}
};

以下是taro info打印出的系统信息:

👽 Taro v1.3.0-beta.1

Taro CLI 1.3.0-beta.1 environment info:
System:
OS: macOS 10.14.4
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
npmPackages:
@tarojs/components: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/mobx: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/mobx-h5: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/mobx-rn: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/plugin-babel: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/plugin-csso: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/plugin-less: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/plugin-uglifyjs: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/rn-runner: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/router: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/taro: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/taro-alipay: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/taro-h5: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/taro-swan: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/taro-weapp: 1.3.0-beta.1 => 1.3.0-beta.1
@tarojs/webpack-runner: 1.3.0-beta.1 => 1.3.0-beta.1
eslint-config-taro: 1.3.0-beta.1 => 1.3.0-beta.1
eslint-plugin-taro: 1.3.0-beta.1 => 1.3.0-beta.1
nervjs: ^1.4.0-beta.3 => 1.4.0-beta.3

onPullDownRefresh 在1.3.0的h5版本 下拉后不会回弹


已解决, 使用Taro.stopPullDownRefresh() 回弹

onPullDownRefresh 在1.3.0的h5版本 下拉后不会回弹

已解决, 使用Taro.stopPullDownRefresh() 回弹

已解决是指在(还未发布的)新版本上解决的么?我们等下一个新版本?

onPullDownRefresh 在1.3.0的h5版本 下拉后不会回弹
已解决, 使用Taro.stopPullDownRefresh() 回弹

已解决是指在(还未发布的)新版本上解决的么?我们等下一个新版本?

是在1.3.0-beat版本已经可以使用的,但是我现在发现一个问题是 下拉的时候 会执行很多次onPullDownRefresh 是需要自己来写节流吗
@Littly

WX20190510-150849@2x
h5 使用canvas时报错了,读取不到值

npm i -g @tarojs/cli@beta 失败
image

taro doctor 碰到的问题的汇总

  1. 目前项目中的 jsx 都是单引号,这个是否可以通过检测 eslint 的配置
 26:19  error  Unexpected usage of doublequote  jsx-quotes
  30:26  error  Unexpected usage of doublequote  jsx-quotes
  1. TS 的报错
  10:19  error  Parsing error: Unexpected token

   8 | 
   9 | interface EmptyProps {
> 10 |   imgType?: keyof typeof IMG_MAP;
     |                   ^
  11 |   children: string;
  1. class 的 private 报错
 10:5  error  Parsing error: private is a reserved word in strict mode

   8 | class XX {
   9 |   constructor(
> 10 |     private readonly storageKey: string,
  1. 默认导出模块是否可以通过配置?
    9:1 error Prefer default export import/prefer-default-export

WX20190510-150849@2x

h5 使用canvas时报错了,读取不到值

canvasId和调用createCanvaContext传入的id对上了吗?

WX20190510-150849@2x
h5 使用canvas时报错了,读取不到值

canvasId和调用createCanvaContext传入的id对上了吗?

对上的,使用之前的版本都可以读取到的

安装cli的时候报错
image

什么时候能劫持render方法就好了,现在的高阶组件好像不能使用父类的render,return ,返回JSX.Element类型的一律会报错。

已全部升级到最新的beta-2,带有tabbar的项目会报错:
image
image

rn 大概多久后支持 hooks

升级1.3后这种写法会导致编译报错

    render() {
        const type = this.state.type

        if ( ['portfolio', 'posts'].includes(type) ) {
            return <Article posts={this.state.posts}></Article>
        } else if ( 'products' === type ) {
            return <Product posts={this.state.posts}></Product>
        }
    }

而调整成这样就不会

    render() {
        const type = this.state.type

        return (
            <View>
                {
                    ['portfolio', 'posts'].includes(type) && <Article posts={this.state.posts}></Article>
                }
                {
                    type === 'products' && <Product posts={this.state.posts}></Product>
                }
            </View>
        )
    }

对应的错误信息

TypeError: Cannot read property 'specifiers' of undefined
    at exit (C:\Users\Administrator.DJ-20170228XRLU\AppData\Roaming\npm\node_mod
ules\@tarojs\cli\dist\h5\index.js:923:68)
    at NodePath._call (C:\Users\Administrator.DJ-20170228XRLU\AppData\Roaming\np
m\node_modules\@tarojs\cli\node_modules\[email protected]@babel-traverse\li
b\path\context.js:76:18)
    at NodePath.call (C:\Users\Administrator.DJ-20170228XRLU\AppData\Roaming\npm
\node_modules\@tarojs\cli\node_modules\[email protected]@babel-traverse\lib
\path\context.js:48:17)
    at NodePath.visit (C:\Users\Administrator.DJ-20170228XRLU\AppData\Roaming\np
m\node_modules\@tarojs\cli\node_modules\[email protected]@babel-traverse\li
b\path\context.js:117:8)
    at TraversalContext.visitQueue (C:\Users\Administrator.DJ-20170228XRLU\AppDa
ta\Roaming\npm\node_modules\@tarojs\cli\node_modules\[email protected]@babe
l-traverse\lib\context.js:150:16)
    at TraversalContext.visitSingle (C:\Users\Administrator.DJ-20170228XRLU\AppD
ata\Roaming\npm\node_modules\@tarojs\cli\node_modules\[email protected]@bab
el-traverse\lib\context.js:108:19)
    at TraversalContext.visit (C:\Users\Administrator.DJ-20170228XRLU\AppData\Ro
aming\npm\node_modules\@tarojs\cli\node_modules\[email protected]@babel-tra
verse\lib\context.js:192:19)
    at Function.traverse.node (C:\Users\Administrator.DJ-20170228XRLU\AppData\Ro
aming\npm\node_modules\@tarojs\cli\node_modules\[email protected]@babel-tra
verse\lib\index.js:114:17)
    at Object.traverse [as default] (C:\Users\Administrator.DJ-20170228XRLU\AppD
ata\Roaming\npm\node_modules\@tarojs\cli\node_modules\[email protected]@bab
el-traverse\lib\index.js:79:12)
    at Compiler.processOthers (C:\Users\Administrator.DJ-20170228XRLU\AppData\Ro
aming\npm\node_modules\@tarojs\cli\dist\h5\index.js:951:33)

还有一段类似的,也是同样的报错,解决方案就是外边加个View,所以现在1.3是render必须有一个容器吗?

    render() {
        return process.env.BUILD_ENV === 'view' ? <Preview/> : <Index/>
    }
    render() {
        const type = this.state.type

        if ( ['portfolio', 'posts'].includes(type) ) {
            return <Article posts={this.state.posts}></Article>
        } else if ( 'products' === type ) {
            return <Product posts={this.state.posts}></Product>
        }
    }

没能复现,给你编译出来了:

<block wx:if="{{$taroCompReady}}">
    <block wx:if="{{anonymousState__temp}}">
        <article compid="{{$compid__0}}"></article>
    </block>
    <block wx:elif="{{'products' === type}}">
        <product compid="{{$compid__1}}"></product>
    </block>
</block>
```js
    render() {
        const type = this.state.type

        if ( ['portfolio', 'posts'].includes(type) ) {
            return <Article posts={this.state.posts}></Article>
        } else if ( 'products' === type ) {
            return <Product posts={this.state.posts}></Product>
        }
    }

没能复现,给你编译出来了:

<block wx:if="{{$taroCompReady}}">
    <block wx:if="{{anonymousState__temp}}">
        <article compid="{{$compid__0}}"></article>
    </block>
    <block wx:elif="{{'products' === type}}">
        <product compid="{{$compid__1}}"></product>
    </block>
</block>

```

测试了一下,weapp是没问题的,h5才会。
刚想弄一个复现仓库,发现仅仅render那段是没问题的,我还需要排查一下。

@yuche 这个仓库是可以复现的,你可以测试一下-> 地址

1.3.0-beta.2 以及 1.2.26中,支付宝小程序无法通过Taro实现跳转分包页面,请问有解决方案吗
经过taro转译的小程序代码,即使在小程序编译器中改为my方式去调用跳转,也无法跳转到分包

又发现其他的问题,让人伤心流泪😂😂😂

提了一个bug -> issue
复现仓库 -> 地址

尝鲜,似乎样式加载有点问题,原来代码在1.2.26下面没问题,升级1.3beta2后,真机上swan样式出错,而且swan在电脑上的工具没问题,只有真机上出现这个情况。
目前发现AtNavbar(版式出错:返回、titile、右侧按钮分别单独占一行)和AtNoticebar(背景颜色和x消失)有问题,当然我只用了少量的taro-ui组件,所以只发现这些。
我尝试自己把taro生成wxml的AtNavBar代码,搬进taro的自定义组件,然后直接套用taro-ui的at-nav-bar几个相关的样式,显示就完全正常了

@yuche 这个仓库是可以复现的,你可以测试一下-> 地址

这个你也新开一个 issue 把

@yuche 这个仓库是可以复现的,你可以测试一下-> 地址

这个你也新开一个 issue 把

好的 -> issue

async handleSubmit() {
}

原有写法<AtButton onClick={this.handleSubmit} circle type="primary">完成</AtButton> 没问题,
现在需要<AtButton onClick={this.handleSubmit.bind(this)} circle type="primary">完成</AtButton>

问题描述
有一个循环渲染的需求,然后目前Taro不支持在render函数之外生成jsx。所以打算在render函数内部用一个箭头表达式来实现递归渲染的需求。示例代码如下

render() {
    const doRender(block) => {
        return (
            <View>
                {block.text}
                {
                    block.children && block.chidren.map(b => {
                        return doRender(b);
                    });
                }
            </View>
        );
    }
    return (
        <View>
            {doRender(this.props.block)}
        </View>
    );
}


期望能得到一个递归渲染的效果,这段代码在h5端能正常使用,但是在微信小程序端编译报错

v1.3.0-beta.2 版本能实现这个需求吗(之前提过一次issue,开发者大大说1.3分支可以,不过现在尝试仍然不行)

本地升级完1.3-beta之后,所有编译,打印栏均无报错,都是显示正常,但是页面不显示。页面显示为空白。升级之前页面显示正常。
这是app.js文件地址
https://github.com/Three-H/proplem/blob/master/1.3app.js

1.3.beta2,taro doctor检测jsxAttributeNameReplacealias不被支持?
以下代码百度,微信端,也没有生效,

static externalClasses = ['custom-class']; //组件接受的外部样式类

1.3.beta2,taro doctor检测jsxAttributeNameReplacealias不被支持?
以下代码百度,微信端,也没有生效,

static externalClasses = ['custom-class']; //组件接受的外部样式类

收到,我们看下

升级 beta.3 时 发现 @tarojs/router 还没有 beta.3 的样子
这是正常的吗?

升级 beta.3 时 发现 @tarojs/router 还没有 beta.3 的样子
这是正常的吗?

不正常

微信截图_20190518103943

升级到 1.3.x 后 Taro.pxTransform 报错。

nb , 升级后不兼容, 微信小程序子组件接收不到 props (defaultProps 也设置了, 老版本不设置也没事), h5 没问题, 急啊! 麻烦帮忙看看

image

image

stylus 从项目根目录引用资源在小程序下编译通过

在 H5模式下编译会报错

为什么 taro-tt 始终不能更新到 1.3 呢?试了好几次了

$ taro info
👽 Taro v1.3.0-beta.3


  Taro CLI 1.3.0-beta.3 environment info:
    System:
      OS: macOS 10.14.4
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 12.1.0 - /usr/local/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/async-await: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/components: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/plugin-babel: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/plugin-csso: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/plugin-sass: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/plugin-uglifyjs: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/redux: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/redux-h5: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/router: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro-alipay: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro-h5: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro-swan: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro-weapp: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/webpack-runner: 1.3.0-beta.3 => 1.3.0-beta.3
      eslint-config-taro: 1.3.0-beta.3 => 1.3.0-beta.3
      eslint-plugin-taro: 1.3.0-beta.3 => 1.3.0-beta.3
      nervjs: ^1.3.9 => 1.3.13
$ taro doctor
👽 Taro v1.3.0-beta.3

✔ 诊断完成

检查 Taro 配置 (/Users/vincent/onebillion/mengmeng-merchant/config/index.js)
  [✓] 没有发现问题

检查依赖
  [!] 检测到最新稳定版本 Taro 1.2.26 , 当前 cli 版本 1.3.0-beta.3
      前往 https://github.com/NervJS/taro/releases 了解详情
  [✗] @tarojs/taro-tt (1.2.26) 与当前使用的 @tarojs/cli (1.3.0-beta.3) 版本不一致, 请更新为统一的版本

检查推荐内容
  [!] 没有检查到常见的测试依赖(jest/mocha/ava/tape/jesmine/karma), 配置测试可以帮助提升项目质量
      可以参考 https://github.com/NervJS/taro-ui-sample 项目, 其中已经包含了完整的测试配置与范例
  [!] 没有检查到 Readme (readme/readme.md/readme.markdown), 编写 Readme 可以方便其他人了解项目

image

就前面的横线一直在转,已经6个小时了,doctor还在诊断 233

希望添加 doctor 的 log 输出,比如目前在诊断什么类目的什么项目

被诊断项目的代码在:https://github.com/xPixv/SteamCN-Mini-Program/tree/790b70d9bbc54ecfdac52fa3d1f9756e12948883 (后面就回滚 1.2.26 了)

Taro info:

> npx taro info
👽 Taro v1.3.0-beta.3

  Taro CLI 1.3.0-beta.3 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 10.15.3 - D:\Program Files\nodejs\node.EXE
      Yarn: 1.16.0 - D:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.9.0 - D:\Program Files\nodejs\npm.CMD

cnpm 无法升级beta3版本

VM2384:1 thirdScriptError
isRenderAction is not defined;at App onError function;at api nextTick callback function
ReferenceError: isRenderAction is not defined
升级到 beta-3之后,一直报这个错

VM2384:1 thirdScriptError
isRenderAction is not defined;at App onError function;at api nextTick callback function
ReferenceError: isRenderAction is not defined
升级到 beta-3之后,一直报这个错

NervJS/taro-ui#584

小程序render外写dom,报错:React is not defined;
fukuan = () => { return ( <View className="f14 common-color fb common-padding border-bottom"> 付款信息 </View> ); };

看了下编译了的代码return React.createElement(View, { className: "f14 common-color fb common-padding border-bottom" }, "\u4ED8\u6B3E\u4FE1\u606F");,但是未定义React

npx taro info
👽 Taro v1.3.0-beta.3

Taro CLI 1.3.0-beta.3 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.14.2 - D:\nodejs\node.EXE
Yarn: 1.13.0 - D:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - D:\nodejs\npm.CMD

小程序render外写dom,报错:React is not defined;
fukuan = () => { return ( <View className="f14 common-color fb common-padding border-bottom"> 付款信息 </View> ); };

看了下编译了的代码return React.createElement(View, { className: "f14 common-color fb common-padding border-bottom" }, "\u4ED8\u6B3E\u4FE1\u606F");,但是未定义React

npx taro info
👽 Taro v1.3.0-beta.3

Taro CLI 1.3.0-beta.3 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.14.2 - D:\nodejs\node.EXE
Yarn: 1.13.0 - D:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - D:\nodejs\npm.CMD

写代码之前先看文档

Taro is not defined
5.22更新:
已经重新提交了一个issue了:
https://github.com/NervJS/taro/issues/3122#issue-446675738
函数组件不支持tsx
在beta1和beta3上都尝试了,无效。
可复现的信息如下(去除掉了我认为无关的信息):
页面pages/demo/index.tsx

import Header from '@/components/demo/Header';
export default class Index extends Component{
  render(){
    return (
      <View>
        <Text>Hello Demo</Text>
        <Header />
      </View>
    )
  }
}

引入的组件(/components/demo/Header.tsx):

import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'

function Header(){
  return (
    <View>
      <Text>Header</Text>
    </View>
  )
}
export default Header

具体报错信息如下:

ReferenceError: Taro is not defined
    at eval (Header.js?b828:4)
    at Module../.temp/components/demo/Header.js (demo_index.js:11)
    at __webpack_require__ (app.js:767)
    at fn (app.js:130)
    at eval (index.js:7)
    at Module../.temp/pages/demo/index.js (demo_index.js:23)
    at __webpack_require__ (app.js:767)
    at fn (app.js:130)

通过第一个错误链接(Header.js?b828:4)点进去看到转换后的代码是这样的

import Nerv from "nervjs";
import { View, Text } from '@tarojs/components';

class Header extends Taro.Component {
  render() {
    return <View>
      <Text>Header</Text>
    </View>;
  }

}

export default Header;

如果把文件名/components/demo/Header.tsx改成/components/demo/Header.js,完全正常……

小程序build不会压缩js和css

config/index.js

plugins: {
    babel: {
      sourceMap: true,
      presets: [
        ['env', {
          modules: false
        }]
      ],
      plugins: [
        'transform-decorators-legacy',
        'transform-class-properties',
        'transform-object-rest-spread'
      ]
    },
    uglify: {
      enable: true,
    },
    csso: {
      enable: true,
    },
  },

快应用端不支持Block组件嘛?

seller[0] && seller[0].image ? seller[0].image.split(',').map((item, idx) => (
                  <SwiperItem key={idx}>
                    {
                      !idx && <View className='store-name'>
                        <View className='title-list'><Text className='title'>{seller[0] && seller[0].storename} </Text> <AtIcon onClick={this.collection} value={this.state.classname == 'classname' ? 'star-2' : 'star'} size='15' /></View>
                        <Text className='introduce'>{seller[0] && seller[0].brief}</Text>
                      </View>
                    }
                    <Image mode='widthFix' src={item}  className='slide-image' />
                  </SwiperItem>
                ))

这一句被编译成
image

获取this.state是ubdefined?

循环引用,不断编译问题
Step1:cli升级到1.3.0-beta.3,编译现有代码,一直在重复编译
image
Step2:
切换cli版本,
npm install -g @tarojs/[email protected] 可以编译成功
npm install -g @tarojs/[email protected] 可以编译成功
npm install -g @tarojs/[email protected] 同样问题

尝试做taro project update,清理node_modules, 删除dist,1.3.0的cli版本同样问题

相关代码部分

image

为什么 taro-tt 始终不能更新到 1.3 呢?试了好几次了

$ taro info
👽 Taro v1.3.0-beta.3


  Taro CLI 1.3.0-beta.3 environment info:
    System:
      OS: macOS 10.14.4
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 12.1.0 - /usr/local/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/async-await: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/components: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/plugin-babel: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/plugin-csso: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/plugin-sass: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/plugin-uglifyjs: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/redux: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/redux-h5: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/router: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro-alipay: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro-h5: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro-swan: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/taro-weapp: 1.3.0-beta.3 => 1.3.0-beta.3
      @tarojs/webpack-runner: 1.3.0-beta.3 => 1.3.0-beta.3
      eslint-config-taro: 1.3.0-beta.3 => 1.3.0-beta.3
      eslint-plugin-taro: 1.3.0-beta.3 => 1.3.0-beta.3
      nervjs: ^1.3.9 => 1.3.13
$ taro doctor
👽 Taro v1.3.0-beta.3

✔ 诊断完成

检查 Taro 配置 (/Users/vincent/onebillion/mengmeng-merchant/config/index.js)
  [✓] 没有发现问题

检查依赖
  [!] 检测到最新稳定版本 Taro 1.2.26 , 当前 cli 版本 1.3.0-beta.3
      前往 https://github.com/NervJS/taro/releases 了解详情
  [✗] @tarojs/taro-tt (1.2.26) 与当前使用的 @tarojs/cli (1.3.0-beta.3) 版本不一致, 请更新为统一的版本

检查推荐内容
  [!] 没有检查到常见的测试依赖(jest/mocha/ava/tape/jesmine/karma), 配置测试可以帮助提升项目质量
      可以参考 https://github.com/NervJS/taro-ui-sample 项目, 其中已经包含了完整的测试配置与范例
  [!] 没有检查到 Readme (readme/readme.md/readme.markdown), 编写 Readme 可以方便其他人了解项目

手动改 package.json 然后重新 yarn/npm install

  "dependencies": {
    "@tarojs/taro-tt": "1.3.0-beta.3",
  }

.eslintignore 配置了

    "jsx-quotes": ["error", "prefer-double"],
    "quotes": ["error", "single", {
      "allowTemplateLiterals": true
    }]

本地直接 esint 正常,用npx taro doctor会出现如下报错

  154:23   error  Unexpected usage of doublequote  jsx-quotes
  155:29   error  Unexpected usage of doublequote  jsx-quotes

同时配置了

  "plugins": ["@typescript-eslint"],
  "parser": "@typescript-eslint/parser"

凡是涉及到 ts 的代码,npx taro doctor都会报错。eslint正常

升级后 会报错 vdSyncBatch 数据传输长度为 1095692 已经超过最大长度

if (process.env.TARO_ENV === 'swan') {
swan.setPageInfo && swan.setPageInfo()
}
TypeError: Cannot set property 'customPageInfo' of undefined

页面的config是否可以传入functional component?因为react hooks的想法是在未来取代class组件,但是如果设置config的话就必须用class组件。

同问 config 在 functional component 怎么传入

Taro CLI 1.3.0-beta.5 environment info:
System:
OS: macOS 10.14.5
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.15.0 - ~.tnvm/versions/alinode/v4.7.0/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.4.1 - ~.tnvm/versions/alinode/v4.7.0/bin/npm
npmPackages:
@tarojs/async-await: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/components: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/plugin-babel: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/plugin-csso: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/plugin-sass: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/plugin-uglifyjs: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/redux: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/redux-h5: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/router: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-alipay: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-h5: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-swan: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-tt: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-weapp: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/webpack-runner: 1.3.0-beta.5 => 1.3.0-beta.5
eslint-config-taro: 1.3.0-beta.5 => 1.3.0-beta.5
eslint-plugin-taro: 1.3.0-beta.5 => 1.3.0-beta.5
nervjs: ^1.4.0-beta.5 => 1.4.0-beta.5
npmGlobalPackages:
typescript: 3.3.4000

声明:以下问题在1.2.x上运行正常;

问题:
1、不兼容1.2.x版本写的逻辑;
2、子组件不进入componentDidShow;
3、this.props 报undefined;
4、wx音频控制抛错,如下图;
image

想试一下1.3.0-beta.5的Context,但是报_index2.default.createContext is not a function,应该是Taro.createContext不存在导致的。请问这个是怎么回事。。。

想试一下1.3.0-beta.5的Context,但是报_index2.default.createContext is not a function,应该是Taro.createContext不存在导致的。请问这个是怎么回事。。。

beta5 只有微信小程序和 h5 有这个 API,h5 你要更新 nervjs 的依赖

想试一下1.3.0-beta.5的Context,但是报_index2.default.createContext is not a function,应该是Taro.createContext不存在导致的。请问这个是怎么回事。。。

beta5 只有微信小程序和 h5 有这个 API,h5 你要更新 nervjs 的依赖

我现在编译的是头条小程序,应该也能开启吧?需要更新什么吗?

  "dependencies": {
    "@bdeefe/api-design": "^0.2.15",
    "@bdeefe/api-design-loading": "0.0.2",
    "@bdeefe/api-design-login": "0.0.4",
    "@bdeefe/api-design-request-micro": "^0.1.5",
    "@tarojs/async-await": "1.3.0-beta.5",
    "@tarojs/components": "1.3.0-beta.5",
    "@tarojs/mobx": "1.3.0-beta.5",
    "@tarojs/mobx-h5": "1.3.0-beta.5",
    "@tarojs/mobx-rn": "1.3.0-beta.5",
    "@tarojs/rn-runner": "1.3.0-beta.5",
    "@tarojs/router": "1.3.0-beta.5",
    "@tarojs/taro": "1.3.0-beta.5",
    "@tarojs/taro-alipay": "1.3.0-beta.5",
    "@tarojs/taro-h5": "1.3.0-beta.5",
    "@tarojs/taro-swan": "1.3.0-beta.5",
    "@tarojs/taro-tt": "1.3.0-beta.5",
    "@tarojs/taro-weapp": "1.3.0-beta.5",
    "@types/classnames": "^2.2.7",
    "@types/lodash": "^4.14.130",
    "classnames": "^2.2.6",
    "dayjs": "^1.8.14",
    "i18next": "^15.1.1",
    "lodash": "^4.17.11",
    "mobx": "4.8.0",
    "nerv-devtools": "^1.4.0-beta.3",
    "nervjs": "^1.4.0-beta.3"
  },
  "devDependencies": {
    "@bdeefe/eslint-config": "^1.0.8",
    "@bdeefe/stylelint-config": "^1.0.5",
    "@ies/starling-cli": "^1.0.5",
    "@tarojs/plugin-babel": "1.3.0-beta.5",
    "@tarojs/plugin-csso": "1.3.0-beta.5",
    "@tarojs/plugin-less": "1.3.0-beta.5",
    "@tarojs/plugin-uglifyjs": "1.3.0-beta.5",
    "@tarojs/webpack-runner": "1.3.0-beta.5",
    "@types/react": "16.3.14",
    "@types/webpack-env": "^1.13.6",
    "@typescript-eslint/eslint-plugin": "^1.9.0",
    "@typescript-eslint/parser": "^1.6.0",
    "babel-eslint": "^8.2.3",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "eslint": "^5.16.0",
    "eslint-config-prettier": "^4.3.0",
    "eslint-config-taro": "1.3.0-beta.5",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-react": "^7.8.2",
    "eslint-plugin-taro": "1.3.0-beta.5",
    "eslint-plugin-typescript-sort-keys": "^0.2.0",
    "fs-extra": "^8.0.1",
    "husky": "^2.3.0",
    "json-stable-stringify": "^1.0.1",
    "node-fetch": "^2.6.0",
    "prettier": "^1.17.1",
    "stylelint": "^9.3.0",
    "stylelint-config-prettier": "^5.2.0",
    "stylelint-config-taro-rn": "1.3.0-beta.3",
    "stylelint-taro-rn": "1.3.0-beta.3",
    "typescript": "^3.0.1"
  }

想试一下1.3.0-beta.5的Context,但是报_index2.default.createContext is not a function,应该是Taro.createContext不存在导致的。请问这个是怎么回事。。。

beta5 只有微信小程序和 h5 有这个 API,h5 你要更新 nervjs 的依赖

我现在编译的是头条小程序,应该也能开启吧?需要更新什么吗?

  "dependencies": {
    "@bdeefe/api-design": "^0.2.15",
    "@bdeefe/api-design-loading": "0.0.2",
    "@bdeefe/api-design-login": "0.0.4",
    "@bdeefe/api-design-request-micro": "^0.1.5",
    "@tarojs/async-await": "1.3.0-beta.5",
    "@tarojs/components": "1.3.0-beta.5",
    "@tarojs/mobx": "1.3.0-beta.5",
    "@tarojs/mobx-h5": "1.3.0-beta.5",
    "@tarojs/mobx-rn": "1.3.0-beta.5",
    "@tarojs/rn-runner": "1.3.0-beta.5",
    "@tarojs/router": "1.3.0-beta.5",
    "@tarojs/taro": "1.3.0-beta.5",
    "@tarojs/taro-alipay": "1.3.0-beta.5",
    "@tarojs/taro-h5": "1.3.0-beta.5",
    "@tarojs/taro-swan": "1.3.0-beta.5",
    "@tarojs/taro-tt": "1.3.0-beta.5",
    "@tarojs/taro-weapp": "1.3.0-beta.5",
    "@types/classnames": "^2.2.7",
    "@types/lodash": "^4.14.130",
    "classnames": "^2.2.6",
    "dayjs": "^1.8.14",
    "i18next": "^15.1.1",
    "lodash": "^4.17.11",
    "mobx": "4.8.0",
    "nerv-devtools": "^1.4.0-beta.3",
    "nervjs": "^1.4.0-beta.3"
  },
  "devDependencies": {
    "@bdeefe/eslint-config": "^1.0.8",
    "@bdeefe/stylelint-config": "^1.0.5",
    "@ies/starling-cli": "^1.0.5",
    "@tarojs/plugin-babel": "1.3.0-beta.5",
    "@tarojs/plugin-csso": "1.3.0-beta.5",
    "@tarojs/plugin-less": "1.3.0-beta.5",
    "@tarojs/plugin-uglifyjs": "1.3.0-beta.5",
    "@tarojs/webpack-runner": "1.3.0-beta.5",
    "@types/react": "16.3.14",
    "@types/webpack-env": "^1.13.6",
    "@typescript-eslint/eslint-plugin": "^1.9.0",
    "@typescript-eslint/parser": "^1.6.0",
    "babel-eslint": "^8.2.3",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-jsx-stylesheet": "^0.6.5",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "eslint": "^5.16.0",
    "eslint-config-prettier": "^4.3.0",
    "eslint-config-taro": "1.3.0-beta.5",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-prettier": "^3.1.0",
    "eslint-plugin-react": "^7.8.2",
    "eslint-plugin-taro": "1.3.0-beta.5",
    "eslint-plugin-typescript-sort-keys": "^0.2.0",
    "fs-extra": "^8.0.1",
    "husky": "^2.3.0",
    "json-stable-stringify": "^1.0.1",
    "node-fetch": "^2.6.0",
    "prettier": "^1.17.1",
    "stylelint": "^9.3.0",
    "stylelint-config-prettier": "^5.2.0",
    "stylelint-config-taro-rn": "1.3.0-beta.3",
    "stylelint-taro-rn": "1.3.0-beta.3",
    "typescript": "^3.0.1"
  }

头条等下个版本

Taro CLI 1.3.0-beta.5 environment info:
System:
OS: macOS 10.14.5
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.15.0 - ~.tnvm/versions/alinode/v4.7.0/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.4.1 - ~.tnvm/versions/alinode/v4.7.0/bin/npm
npmPackages:
@tarojs/async-await: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/components: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/plugin-babel: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/plugin-csso: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/plugin-sass: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/plugin-uglifyjs: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/redux: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/redux-h5: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/router: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-alipay: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-h5: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-swan: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-tt: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/taro-weapp: 1.3.0-beta.5 => 1.3.0-beta.5
@tarojs/webpack-runner: 1.3.0-beta.5 => 1.3.0-beta.5
eslint-config-taro: 1.3.0-beta.5 => 1.3.0-beta.5
eslint-plugin-taro: 1.3.0-beta.5 => 1.3.0-beta.5
nervjs: ^1.4.0-beta.5 => 1.4.0-beta.5
npmGlobalPackages:
typescript: 3.3.4000

声明:以下问题在1.2.x上运行正常;

问题:
1、不兼容1.2.x版本写的逻辑;
2、子组件不进入componentDidShow;
3、this.props 报undefined;
4、wx音频控制抛错,如下图;
image

我也遇到了上述问题

tt小程序context是undefined。发现1.3.0-beta.6支持了context,就试了一下。但是设置contextType之后,this.context是undefined

import { Component } from "@tarojs/taro";
import { View } from "@tarojs/components";
import { ThemeContext } from "../dsf";

export default class Ddd extends Component {
  public static contextType = ThemeContext

  public render() {
    console.error('adsf', this.context)
    return (
      <View>234</View>
    )
  }
}

tt小程序context是undefined。发现1.3.0-beta.6支持了context,就试了一下。但是设置contextType之后,this.context是undefined

import { Component } from "@tarojs/taro";
import { View } from "@tarojs/components";
import { ThemeContext } from "../dsf";

export default class Ddd extends Component {
  public static contextType = ThemeContext

  public render() {
    console.error('adsf', this.context)
    return (
      <View>234</View>
    )
  }
}

去提一个 issue 把

发现1.3.0-beta.6支持了context,就试了一下。但是设置contextType之后,this.context是undefined

https://github.com/NervJS/taro/issues/3301

@BrookShuihuaLee 可以升级到 1.3.0-beta.8 试试

// 在css中多行文本溢出显示...
{
   display: -webkit-box;
   -webkit-line-clamp: 2;
    overflow: hidden;
    -webkit-box-orient: vertical;
}
//  但是上面的css并未如期显示在h5页面上,h5打包好后会少-webkit-box-orient: vertical;这句,目前解决方法是写在标签上

@JokerLoLgrey

display: -webkit-box;
-webkit-line-clamp: 2;
overflow: hidden;
/*! autoprefixer: ignore next */
-webkit-box-orient: vertical;

你試試這個,我們用這個是可以的。

小程序编译不了

【版本】
`👽 Taro v1.3.0-beta.8

Taro CLI 1.3.0-beta.8 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.15.1 - D:\GHU\nodejs\node.EXE
npm: 6.4.1 - D:\GHU\nodejs\npm.CMD
【报错信息】 生成 页面样式 dist/pages/goods-info/index.wxss
生成 组件配置 dist/dist/pages/cart/cart-item/index.json
生成 组件逻辑 dist/dist/pages/cart/cart-item/index.js
生成 组件模板 dist/dist/pages/cart/cart-item/index.wxml
生成 组件样式 dist/dist/pages/cart/cart-item/index.wxss
生成 页面配置 dist/pages/cart/index.json
生成 页面逻辑 dist/pages/cart/index.js
生成 页面模板 dist/pages/cart/index.wxml
生成 页面样式 dist/pages/cart/index.wxss
(node:14868) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'buffer'
at Object.openSync (fs.js:439:3)
at Object.readFileSync (fs.js:344:35)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:175:30
at Generator.next ()
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:7:71
at new Promise ()
at __awaiter (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:3:12)
at recursiveRequire (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:174:12)
at resolveNpmFilesPath (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:53:9)
at CallExpression (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:113:53)
(node:14868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14868) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:14868) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'fs'
at Object.openSync (fs.js:439:3)
at Object.readFileSync (fs.js:344:35)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:175:30
at Generator.next ()
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:7:71
at new Promise ()
at __awaiter (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:3:12)
at recursiveRequire (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:174:12)
at resolveNpmFilesPath (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:53:9)
at CallExpression (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:113:53)
(node:14868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:14868) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'util'
at Object.openSync (fs.js:439:3)
at Object.readFileSync (fs.js:344:35)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:175:30
at Generator.next ()
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:7:71
at new Promise ()
at __awaiter (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:3:12)
at recursiveRequire (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:174:12)
at resolveNpmFilesPath (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:53:9)
at CallExpression (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:113:53)
(node:14868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:14868) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'stream'
at Object.openSync (fs.js:439:3)
at Object.readFileSync (fs.js:344:35)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:175:30
at Generator.next ()
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:7:71
at new Promise ()
at __awaiter (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:3:12)
at recursiveRequire (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:174:12)
at resolveNpmFilesPath (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:53:9)
at CallExpression (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:113:53)
(node:14868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:14868) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'zlib'
at Object.openSync (fs.js:439:3)
at Object.readFileSync (fs.js:344:35)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:175:30
at Generator.next ()
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:7:71
at new Promise ()
at __awaiter (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:3:12)
at recursiveRequire (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:174:12)
at resolveNpmFilesPath (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:53:9)
at CallExpression (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:113:53)
(node:14868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
(node:14868) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'assert'
at Object.openSync (fs.js:439:3)
at Object.readFileSync (fs.js:344:35)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:175:30
at Generator.next ()
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:7:71
at new Promise ()
at __awaiter (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:3:12)
at recursiveRequire (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:174:12)
at resolveNpmFilesPath (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:53:9)
at CallExpression (C:\Users\Administrator\AppData\Roaming\npm\node_modules\@tarojs\clidist\util\resolve_npm_files.js:113:53)
(node:14868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)`

【package.json】
{ "name": "GoJoy-H5", "version": "1.0.0", "private": true, "description": "", "main": "index.js", "scripts": { "build:weapp": "taro build --type weapp", "build:swan": "taro build --type swan", "build:alipay": "taro build --type alipay", "build:tt": "taro build --type tt", "build:h5": "taro build --type h5", "build:rn": "taro build --type rn", "dev:weapp": "npm run build:weapp -- --watch", "dev:swan": "npm run build:swan -- --watch", "dev:alipay": "npm run build:alipay -- --watch", "dev:tt": "npm run build:tt -- --watch", "dev:h5": "npm run build:h5 -- --watch", "dev:rn": "npm run build:rn -- --watch" }, "author": "", "license": "MIT", "dependencies": { "@tarojs/components": "1.3.0-beta.8", "@tarojs/mobx": "1.3.0-beta.8", "@tarojs/mobx-h5": "1.3.0-beta.8", "@tarojs/mobx-rn": "1.3.0-beta.8", "@tarojs/rn-runner": "1.3.0-beta.8", "@tarojs/router": "1.3.0-beta.8", "@tarojs/taro": "1.3.0-beta.8", "@tarojs/taro-alipay": "1.3.0-beta.8", "@tarojs/taro-h5": "1.3.0-beta.8", "@tarojs/taro-swan": "1.3.0-beta.8", "@tarojs/taro-tt": "1.3.0-beta.8", "@tarojs/taro-weapp": "1.3.0-beta.8", "axios": "^0.18.0", "cookies-js": "^1.2.3", "copy-to-clipboard": "^3.0.8", "marked": "^0.6.2", "mobx": "^4.8.0", "nerv-devtools": "^1.4.0", "nervjs": "^1.4.0", "qrcode": "^1.3.3", "react-zmage": "^0.7.5", "taro-ui": "^2.1.0" }, "devDependencies": { "@types/react": "16.3.14", "@types/webpack-env": "^1.13.6", "@tarojs/plugin-babel": "1.3.0-beta.8", "@tarojs/plugin-csso": "1.3.0-beta.8", "@tarojs/plugin-sass": "1.3.0-beta.8", "@tarojs/plugin-uglifyjs": "1.3.0-beta.8", "@tarojs/webpack-runner": "1.3.0-beta.8", "babel-plugin-transform-class-properties": "^6.24.1", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-jsx-stylesheet": "^0.6.5", "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-preset-env": "^1.6.1", "babel-eslint": "^8.2.3", "eslint": "^4.19.1", "eslint-config-taro": "1.3.0-beta.8", "eslint-plugin-react": "^7.8.2", "eslint-plugin-import": "^2.12.0", "eslint-plugin-taro": "1.3.0-beta.8" } }

【H5编译报错】
`创建 发现文件 src\components\wemark\prism.wxss
创建 发现文件 src\components\wemark\remarkable.js

<--- Last few GCs --->

[12512:000001FAAA954F50] 7903 ms: Scavenge 118.1 (140.7) -> 110.0 (145.7) MB, 26.9 / 0.0 ms (average mu = 0.991, current mu = 0.992) allocation failure
[12512:000001FAAA954F50] 7944 ms: Scavenge 121.9 (145.7) -> 110.9 (148.7) MB, 2.6 / 0.0 ms (average mu = 0.991, current mu = 0.992) allocation failure
[12512:000001FAAA954F50] 8056 ms: Scavenge 125.3 (148.7) -> 118.9 (151.2) MB, 8.6 / 0.0 ms (average mu = 0.991, current mu = 0.992) allocation failure

<--- JS stacktrace --->
Cannot get stack trace in GC.
FATAL ERROR: NewSpace::Rebalance Allocation failed - JavaScript heap out of memory
1: 00007FF6059D0EFA
2: 00007FF6059AA296
3: 00007FF6059AAC80
4: 00007FF605C409BE
5: 00007FF605C408EF
6: 00007FF60617E954
7: 00007FF605E5C02A
8: 00007FF6061753C1
9: 00007FF60617449E
10: 00007FF60617362C
11: 00007FF60617C5A7
12: 00007FF60617C626
13: 00007FF605D1F278
14: 00007FF605D1FBF2
15: 00007FF605F63120
16: 00007FF605F60199
17: 00007FF605F60641
18: 00007FF6061C2633
19: 0000034A7655C5C1
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] build:h5: taro build --type h5
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the [email protected] build:h5 script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache_logs\2019-06-12T03_09_35_452Z-debug.log`

v1.3.0-beta.8 h5编译失败 小程序没问题
ℹ️ Listening at http://127.0.0.1:10086/

监听文件修改中...

🙅   Failed to compile.

  Error: webpack-internal:///./node_modules/webpack/buildin/harmony-module.js:29
  /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./harmony-module.js */ "./node_modules/webpack/buildin/harmony-module.js")(m  odule)))//# sourceURL=[module]
                                                                                                                                            ^
  TypeError: __webpack_require__(...) is not a function

  - harmony-module.js:29 eval
    [.]/[webpack]/buildin/harmony-module.js:29:139

  - index.html:1882 Module../node_modules/webpack/buildin/harmony-module.js
    D:/project/cloudpin_mini/src/index.html:1882:1

  - index.html:684 __webpack_require__
    D:/project/cloudpin_mini/src/index.html:684:30

  - index.html:61 fn
    D:/project/cloudpin_mini/src/index.html:61:20

  - global.js:24 eval
    [.]/[webpack]/buildin/global.js:24:41

  - index.html:1870 Module../node_modules/webpack/buildin/global.js
    D:/project/cloudpin_mini/src/index.html:1870:1

  - index.html:684 __webpack_require__
    D:/project/cloudpin_mini/src/index.html:684:30

  - index.html:61 fn
    D:/project/cloudpin_mini/src/index.html:61:20

  - lodash.js:17101 eval
    [.]/[lodash]/lodash.js:17101:41

  - index.html:1858 Object../node_modules/lodash/lodash.js
    D:/project/cloudpin_mini/src/index.html:1858:1

PS D:\project\cloudpin_mini> taro info
👽 Taro v1.3.0-beta.8

Taro CLI 1.3.0-beta.8 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.14.2 - D:\nodejs\node.EXE
Yarn: 1.13.0 - D:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - D:\nodejs\npm.CMD

确定项目内的tarojs依赖都是v1.3.0-beta.8
image

------补充
是因为config/index 里babel 的plugin 配置了'transform-runtime' 导致,删了就好了
至于为什么会导致,就不知道了

转为h5,其他页面用router.push回到首页,首页都会重复显示,这个问题只能通过在h5页面都用router.replace来解决吗

编译rn时,.rn_temp目录中没有bandle目录,也没有自动打开一个终端。请问,1.3.0版本中说不再使用Expo,那现在官方文档是否是已经更新了的状态?

函数式组件中的 jsx 无法拿到正确的 this:

class MyComponent extends Taro.Component {
state = {
  count: 0
};
renderMyComponent() {
  console.log(this.state.count); // 能够正确打印
  const { count } = this.state;
  return <Text>{this.state.count} {count}</Text>; // 前一个是 undefined,后一个正确 count 值
}
render () {
    return (
      <View className='index' text='test text'>
        <Text>Hello world! {this.state.count}</Text>
        <View onClick={() => {
          this.setState({
            count: this.state.count + 1
          });
        }}>{this.renderMyComponent()}</View>
      </View>
    )
  }
}
}

这个虽然在控制台中会提示,但是想知道这样限制的原因?

Was this page helpful?
0 / 5 - 0 ratings