[渲染层网络层错误] Failed to load local image resource /pages/xxx/undefined the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error)(env: Windows,mp,1.06.2504060; lib: 3.11.3)

uniapp开发中在小程序平台遇到如上错误提示,需要查看的是初始值为null的变量在视图中的使用位置。

比如,以下代码中headerBgType如果初始值为null,那么会有如上错误提示。

<view class="header"
			:style="'background-image: url(' + headerBgMap[headerBgType].image + ');height: ' + headerBgMap[headerBgType].height + ';'">
		</view>

总结:视图中直接引用的变量应该有合理的初始值,如果是null,需要加v-if判断。

Comments

No comments yet. Why don’t you start the discussion?

发表回复