globalProperties
中响应式变量的疑惑
#7023
Unanswered
llk2yq
asked this question in
Help/Questions
Replies: 1 comment 1 reply
-
因为在模版编译的时候没办法知道全局变量是否存在以及类型是什么,也就没办法自动unref。而组件内部定义的变量是可以在编译时分析出类型的。 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
代码链接
在代码链接里,页面内部定义的响应式变量(
isBig
)是按预期工作的,但是全局定义的响应式变量(isSmall
)却和预期不一样,不通过.value
可以访问到值,通过.value
也可以访问到值,且在三元表达式里是对象。疑惑:
这是设计如此吗,全局属性里不支持响应式?还是说写法问题?还是说这是个bug(和组件内部定义的表现不一致)?
Beta Was this translation helpful? Give feedback.
All reactions