我想反馈一个 Bug
* 如何复现?
比如项目文件结构如下
image/
image/1.png
pages/
pages/index/index.wxml
template/
template/test.wxml
app.js
app.json
app.wxss
现在自定义了一个template
<template name="empty-page"> <image class="empty-page-img" src="../image/1.png" mode="aspectFit"></image></template> |
然后在index页面中引用他
<import src="../../template/test.wxml" /><template is="empty-page"/> |
页面会出现错误,说图片不存在
只有当template中图片路径调整为index的图片路径时,图片才能正确显示
当然这样也可以操作,可是template就用处不大了-----因为当要引入图片时,只能用在路径相同的页面上。

你这里的图片是相对路径,所以到index.wxml是相对index.wxml,而不是test.wxml。应该使用绝对路径的 /image/1.png。