-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
项目编译后,component标签上ref属性对应的响应式对象为空,开发环境下正常 #4866
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This is not a valid reproduction but I noticed in your code you should use import _HomeView from './HomeView.vue'
const HomeView = markRaw(_HomeView)
const currentTabComponent = computed(() => {
switch (currentTab.value) {
case 'Home' : return HomeView
case 'Posts' : return PostsView
case 'Archive' : return ArchiveView
}
}) Remember to use the forum or the Discord chat to ask questions! |
@posva Thank you for your reply, but this plan did not work.
The component ref attribute is obtained by currentTabRef function and the corresponding $refs object(Home_View、Posts_View、Archive_View) is defined also Log Home_View.value, Posts_View.value, and Archive_View.value per second. In dev environment, Home_View.value,Posts_View.value and Archive_View.value get the correct values,but after build, Home_View.value,Posts_View.value and Archive_View.value is always null |
I simplified it sfc.vuejs.org/ |
Will this issue be fixed in the next release? |
It seems can not compile the template inside setup when there exists dynamic ref... |
@651778286 不只有refs有问题 , 我在setup script 中 |
@yjj5855 解决了吗? 我也是碰到了这个问题, 从vite的issue过来的 我的版本是 |
@llcat setup script 和 普通script 中的数据不互通目前看来, 一个vue文件只能写一种script, 文档中没有明确说明容易给人错觉 |
是的, 翻了几个issue, debug后发现确实不互通, 主要是 |
我也遇到了,只有部分浏览器是 undefined |
This is a design flaw in the way dynamic refs are handled in For now, the workaround is to create a plain object to hold the refs: |
Closing this as a duplicate of #11373 for better tracking as the new one is in English |
Version
3.2.20
Reproduction link
sfc.vuejs.org/
Steps to reproduce
1、在开发环境下,切换分页后,当前分页的ref对象(Home_View.value/Posts_View.value/Archive_View.value)不为空
2、运行vite build进行编译之后,部署到服务器上运行,切换分页后,当前分页的ref对象为空
What is expected?
编译后ref对象不为空
What is actually happening?
编译后ref对象为空
The text was updated successfully, but these errors were encountered: