对于资源类参数的绑定,一定要require 进来或者使用相对路径,不能使用绝对路径
<image class="switch" :src="irri.switch ? switchOnPath : switchOffPath" mode=""></image>
data() {
return {
// switchOnPath: require('@/static/image/mipmap-xhdpi/on.png'),
// switchOffPath: require('@/static/image/mipmap-xhdpi/off.png')
switchOnPath: '../../static/image/mipmap-xhdpi/on.png',
switchOffPath: '../../static/image/mipmap-xhdpi/off.png'
}
另外 可能是uni-app 的一个bug 文件夹名如果是用的 icon 里面放的是png 的话,在app 里面调用图片会加载不了,但是网页很正常, 另外 路劲中不能使用中文
background: url('~@/static/icon/header_press_on.png') no-repeat center;
文件夹名改为 bg后
background: url('~@/static/bg/header_press_on.png') no-repeat center;