Subscribe on changes!

defineProps is not defined

avatar
May 12th 2023

Vue version

3.3.1

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-ptrymz?file=src/components/HelloWorld.vue

Steps to reproduce

  1. open url: https://stackblitz.com/edit/vitejs-vite-ptrymz?file=src/components/HelloWorld.vue
  2. open browers tools
  3. have a error is defineProps is not defined

What is expected?

与 vue3.2 保持一致

What is actually happening?

貌似 setup作用域没导出 某些函数

System Info

System: any
npmPackages: any
vue: 3.3.1

Any additional comments?

No response

avatar
May 12th 2023

The same is true for 3.2.47 in the playground. In which version 3.2 can you use this? I think compiled macros will not be parsed in runtime-related methods, you should use them in the setup top-level scope or supported compiled macro functions

avatar
May 12th 2023

The same is true for 3.2.47 in the playground. In which version 3.2 can you use this? I think compiled macros will not be parsed in runtime-related methods, you should use them in the setup top-level scope or supported compiled macro functions

vue@3.2.47 ok

avatar
May 12th 2023

image Maybe there is something wrong with the playground too

avatar
May 12th 2023

image Maybe there is something wrong with the playground too

i know because toRefs

avatar
May 12th 2023

So toRefs, as a runtime method, wraps a compilation macro, and it will not process it in the compilation phase, even in 3.2.47

avatar
May 12th 2023

@1739616529 You need to update @vitejs/plugin-vue.

image

avatar
May 12th 2023

The linked StackBlitz link seems to have been edited and no longer demonstrates the issue - but based on the conversation, you cannot use toRefs to directly wrap a macro. This has always been the case even in 3.2.47.