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

使用vite打包后 属性丢失 #6244

Closed
7 tasks done
yjj5855 opened this issue Dec 23, 2021 · 1 comment
Closed
7 tasks done

使用vite打包后 属性丢失 #6244

yjj5855 opened this issue Dec 23, 2021 · 1 comment

Comments

@yjj5855
Copy link

yjj5855 commented Dec 23, 2021

Describe the bug

在 script setup 中定义的属性, 在script 中无法获取, 开发环境可以获取, 使用 vite build 打包后无法获取 输出undefined

Reproduction

<script setup>
import {ref} from 'vue'
const ref_form = ref(null)
</script>

<script>
export default {
  mounted() {
    setInterval(() => {
      console.log(this.ref_form)
    }, 500)
  }
}
</script>

<template>
  <div>
    <div ref="ref_form">
      asfasfsaf
    </div>
    {{ ref_form }}
  </div>
</template>

企业微信截图_16402417333856

企业微信截图_16402417622644

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 3.01 GB / 15.90 GB
  Binaries:
    Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 92.0.4515.131
    Edge: Spartan (44.19041.1266.0), Chromium (96.0.1054.62)
    Internet Explorer: 11.0.19041.1202

Used Package Manager

npm

Logs

No response

Validations

@yjj5855
Copy link
Author

yjj5855 commented Dec 24, 2021

不是vite的问题 我使用vue cli 也创建了一个空项目 把代码改成上面这样 也是获取不到ref_form
应该是vue-next编译的问题吧?

@yjj5855 yjj5855 closed this as completed Dec 24, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant