解決vue3傳屬性時(shí)報(bào)錯[Vue?warn]:Component?is?missing?template?or?render?function
上網(wǎng)查這個問題,解決方案很多,沒有一款適合我。。。先說我的解決辦法,如果解決不了再往下看,我的原因是 用的子組件的ref和子組件的標(biāo)簽名一樣了:
<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 改個名字就好了。。。
使用技術(shù):vue3+ts
用的props傳值,本來都好好的,后來發(fā)現(xiàn)給一個子組件傳值發(fā)生變化的時(shí)候,子組件展示有問題并且報(bào)警告:[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)上常見的別的解決辦法:
- 子組件是空白的
- 子組件引入的時(shí)候沒有寫.vue
import ChildComponent1from './ChildComponent1'; // 改為 import ChildComponent1from './ChildComponent1.vue';
總結(jié)
到此這篇關(guān)于解決vue3傳屬性時(shí)報(bào)錯[Vue warn]:Component is missing template or render function的文章就介紹到這了,更多相關(guān)vue3傳屬性報(bào)錯[Vue warn]內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue-cli基礎(chǔ)配置及webpack配置修改的完整步驟
這篇文章主要給大家介紹了關(guān)于vue-cli基礎(chǔ)配置及webpack配置修改的完整步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者使用vue-cli具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10淺談vue實(shí)現(xiàn)數(shù)據(jù)監(jiān)聽的函數(shù) Object.defineProperty
本篇文章主要介紹了淺談vue實(shí)現(xiàn)數(shù)據(jù)監(jiān)聽的函數(shù) Object.defineProperty,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06使用element-ui實(shí)現(xiàn)行合并過程
這篇文章主要介紹了使用element-ui實(shí)現(xiàn)行合并過程,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-08-08Element InputNumber 計(jì)數(shù)器的實(shí)現(xiàn)示例
這篇文章主要介紹了Element InputNumber 計(jì)數(shù)器的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08關(guān)于vue-socket.io使用及版本原因消息無法監(jiān)聽bug
這篇文章主要介紹了關(guān)于vue-socket.io使用及版本原因消息無法監(jiān)聽bug,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10vite+vue3中require?is?not?defined問題及解決
這篇文章主要介紹了vite+vue3中require?is?not?defined問題及解決方案,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-05-05