解決vue3傳屬性時報錯[Vue?warn]:Component?is?missing?template?or?render?function
上網(wǎng)查這個問題,解決方案很多,沒有一款適合我。。。先說我的解決辦法,如果解決不了再往下看,我的原因是 用的子組件的ref和子組件的標簽名一樣了:
<ChildComponent1 ref="ChildComponent1" :parent-data="data" > <template #slot-content> <div>插槽 content 內(nèi)容000000000</div> </template> <template #slot-footer> <div>插槽 footer 內(nèi)容11111111</div> </template> </ChildComponent1>
給 ref 改個名字就好了。。。
使用技術:vue3+ts
用的props傳值,本來都好好的,后來發(fā)現(xiàn)給一個子組件傳值發(fā)生變化的時候,子組件展示有問題并且報警告:[Vue warn]: Component is missing template or render function
[Vue warn]: Component is missing template or render function
意思很明顯,好像是我寫了空白的缺少 template和script的組件,但問題是我組件內(nèi)容是完整的?。?/p>
<template> <div class=""> 組件1 </div> </template> <script lang="ts" setup> import { ref, reactive, defineEmits, onBeforeMount, onMounted } from 'vue'; const data: any = reactive({}); </script> <script lang="ts"> export default { name: 'ChildComponent1', data() { return {}; }, }; </script> <style lang="less" scoped></style>
如果你的問題不是這個,可以看看網(wǎng)上常見的別的解決辦法:
- 子組件是空白的
- 子組件引入的時候沒有寫.vue
import ChildComponent1from './ChildComponent1'; // 改為 import ChildComponent1from './ChildComponent1.vue';
總結(jié)
到此這篇關于解決vue3傳屬性時報錯[Vue warn]:Component is missing template or render function的文章就介紹到這了,更多相關vue3傳屬性報錯[Vue warn]內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
淺談vue實現(xiàn)數(shù)據(jù)監(jiān)聽的函數(shù) Object.defineProperty
本篇文章主要介紹了淺談vue實現(xiàn)數(shù)據(jù)監(jiān)聽的函數(shù) Object.defineProperty,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06Element InputNumber 計數(shù)器的實現(xiàn)示例
這篇文章主要介紹了Element InputNumber 計數(shù)器的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-08-08關于vue-socket.io使用及版本原因消息無法監(jiān)聽bug
這篇文章主要介紹了關于vue-socket.io使用及版本原因消息無法監(jiān)聽bug,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10vite+vue3中require?is?not?defined問題及解決
這篇文章主要介紹了vite+vue3中require?is?not?defined問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-05-05