0


当vue3 报错 Cannot read properties of null (reading ‘style‘)

当你在编写代码时 发现页面不及时刷新了 浏览器控制台报下面的错误
时刚看到的时候会一很懵 那么原因是什么呢

 Cannot read properties ofnull(reading 'style')
    at patchStyle(runtime-dom.esm-bundler.js:104:22)

原因是:尽管Vue 3允许一个组件模板中存在多个元素,但是如果你这样写,有时会出现上述错误。

解决方法:在模板内你写的多个标签外面包裹一层元素,或者给某个标签添加v-bind=“$attrs”。

请注意:如果你的模板中存在if else语句,虽然你认为它应该是一个元素,但在运行时仍会报上述错误。


本文转载自: https://blog.csdn.net/xuehongnizhao/article/details/129261542
版权归原作者 事实证明 所有, 如有侵权,请联系我们删除。

“当vue3 报错 Cannot read properties of null (reading ‘style‘)”的评论:

还没有评论