页面:
<img :src="weatherDatas.imgPath">
js:
//获取天气数据
getWeather(lon,lat){
var that = this;
//获取图片的json数组**
var weatherImgData= require("../../assets/data/weather.json").data;
this.$axios.get(httpcqpisa + "/cloud/meto/getWeatherDataList?areaCode="+this.areaCode+"&lat="+lat+"&lon="+lon)
.then(res => {
if(res.data && res.data.length){
that.weatherDatas = res.data[0];
weatherImgData.forEach(item => {
if(that.weatherDatas.WEP == item.name){
var str = '../../../static/image/weather/'+item.imgPath
//获取图片路径****
that.weatherDatas.imgPath = require( '../../../static/image/weather/'+item.imgPath);
}
})
}
}).catch(error => { console.log(error) });
},
打包后的路径就对了