1 | <script setup> |
在 Vue3 編譯時出現這個警告
[@vue/compiler-sfc] defineProps is a compiler macro and no longer needs to be imported.
[@vue/compiler-sfc] defineEmits is a compiler macro and no longer needs to be imported.
解譯bug
⚠️ @vue/compiler-sfc
Vue 單文件組件(SFC) 編譯警告
⚠️defineProps is a compiler macro and no longer needs to be imported.
defineProps 是一個編譯器巨集,不再需要導入。
⚠️defineEmits is a compiler macro and no longer needs to be imported.
defineEmits 是一個編譯器巨集,不再需要導入。
錯誤原因
defineProps和 defineEmits 都是只在 <script setup>
中才能使用的編譯器巨集。
他們不需要導入且會隨著 <script setup>
處理過程一同被編譯掉
如何解決
將 import 的 defineProps
、defineEmits
移除即可
1 | <script setup> |
如果這篇文章對你有幫助,請幫小編按個讚👍~你的鼓勵是我分享的動力😊