uniapp 开发小程序,封装一个方法,让图片使用线上地址

1.在main.js文件中,添加以下代码:

在这里插入图片描述

复制使用:

// 图片使用网络地址
Vue.prototype.localImgSrc = function(img){
	//项目的地址域名,例如百度
	return "https://baidu.cn/static/index/images/" + img;
}

2.在页面中直接使用:

在这里插入图片描述

<image :src="localImgSrc('[email protected]')" mode=""></image>

ok!

猜你喜欢

转载自blog.csdn.net/weixin_48596030/article/details/132554686