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

三元运算符/条件渲染似乎有问题 #1423

Closed
yuhong-l opened this issue Dec 8, 2018 · 3 comments
Closed

三元运算符/条件渲染似乎有问题 #1423

yuhong-l opened this issue Dec 8, 2018 · 3 comments
Assignees

Comments

@yuhong-l
Copy link

yuhong-l commented Dec 8, 2018

问题描述
class里有一个本地变量是location, string类型 值为"默认位置"
render方法里是

test{this.location}
{this.location === "" ? "123" : this.location + "-"}test

render后的结果里 第一个{this.location}能渲染出正确的值
第二个{}里渲染出得结果为
image
也就是说在{条件渲染返回值}得到的location变量值为undefined

复现步骤
[复现问题的步骤]

  1. 创建本地变量
  2. 如前面所描述,在用三目表达式返回值。

[或者可以直接贴源代码,能贴文字就不要截图]

// 这里可以贴代码

期望行为
正确返回值
报错信息

系统信息
👽 Taro v1.2.0-beta.2
weapp

补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

@taro-bot
Copy link

taro-bot bot commented Dec 8, 2018

欢迎提交 Issue~

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

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

Good luck and happy coding~

@yuhong-l yuhong-l changed the title observable变量的条件渲染似乎有问题 三元运算符的条件渲染似乎有问题 Dec 8, 2018
@yuhong-l yuhong-l changed the title 三元运算符的条件渲染似乎有问题 三元运算符/条件渲染似乎有问题 Dec 8, 2018
@yuhong-l
Copy link
Author

yuhong-l commented Dec 8, 2018

似乎与 #862 中提到的第一个问题类似

@yuche yuche added the 编译器 label Dec 9, 2018
@taro-bot
Copy link

taro-bot bot commented Dec 9, 2018

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

2 participants