在uniapp中,可以通过uni.getImageInfo()方法获取本地图片路径。具体步骤如下:
引入uniapp的api:import uni from 'uni'
使用uni.getImageInfo()方法获取图片信息,传入图片路径作为参数:uni.getImageInfo({src: '本地图片路径'})
在方法的回调函数中,可以通过res.path获取本地图片路径:res.path
示例代码如下:
import uni from 'uni'uni.getImageInfo({ src: '本地图片路径', success: function(res) { console.log(res.path) // 输出本地图片路径 }})需要注意的是,本地图片路径必须是相对于当前页面的路径,可以使用相对路径(如’…/images/test.png’)或绝对路径(如’/static/images/test.png’)。


