vitepress打包报错 TypeError: Cannot read properties of null (reading 'alt')
时间: 2023-08-25 16:18:43 浏览: 274
根据引用和引用的内容,问题可能是在打包过程中,vitepress遇到了一个空值的情况,导致报错"TypeError: Cannot read properties of null (reading 'alt')"。这个错误可能是因为在渲染模块时,对于某个属性进行了读取,而该属性的值为空(null)。为了解决这个问题,可以通过在加载该模块时添加一个判断语句来避免渲染空值的情况。具体的做法是,在li标签中添加一个v-if的判断语句,当goods为空时,取消对该模块的渲染。以下是修改后的代码示例:
```html
<li @click="gotoProduct" v-if="goods != null">
<img v-bind:src="goods<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [关于Error in render: "TypeError: Cannot read property '0' of null"问题的解决方法](https://blog.csdn.net/qq_42985101/article/details/102056925)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [vant轮播图组件滑动报错Uncaught TypeError: Cannot read property ‘width‘ of null解决方案](https://blog.csdn.net/qq_37493515/article/details/117132216)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文