Vue3報錯:Extraneous non-props attributes (style) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
翻譯是:無關(guān)的非道具屬性(樣式)被傳遞給組件,但由于組件呈現(xiàn)片段或文本根節(jié)點而無法自動繼承。
出現(xiàn)這個錯誤的原因是在組件的節(jié)點上添加了樣式,也就是
<組件 style='display:none'></組件>
我本來的思路是想讓這個組件隱藏起來的,但這樣行不通文章來源:http://www.zghlxwxcb.cn/news/detail-582125.html
所以解決辦法就是在組件外套一層div,即文章來源地址http://www.zghlxwxcb.cn/news/detail-582125.html
<div style='display:none'>
<組件></組件>
</div>
到了這里,關(guān)于Vue3報錯:Extraneous non-props attributes (style) were passed to component but could not be automatical的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!