problem description
I want to dynamically change the path of json to display different images based on one of the img src data returned from the background.
for example, if the background returns [{"ALARMNAME": "gale yellow warning"}], then I will show the picture of the gale yellow warning
[{"ALARMNAME": "blizzard yellow warning"}] then I will show the picture of the blizzard warning
the environmental background of the problems and what methods you have tried
tried a lot without success
related codes
/ / Please paste the code text below (do not replace the code with pictures)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="../css/mui.min.css">
<!-- -->
<link rel="stylesheet" href="../css/mui.picker.min.css">
<style type="text/css">
</style>
</head>
<body>
<!-- -->
<div id="weather" class="mui-content">
<!-- -->
<div class="mui-control-content mui-active">
<ul v-for="w in weatherwaring">
<li>
<a>
<img src="../img/icon/weatherIcon/df-y.png">//
<div>
{{w.ALARMNAME}}//src
{{w.PUBLISHTIME}}
</div>
</a>
<ul>
<li>
<span>:
{{w.CONTENT}}
</span>
</li>
</ul>
</li>
</ul>
</div>
</div>
</body>
<script src="../js/mui.min.js"></script>
<script src="../js/vue.2.5.17.js"></script>
<script src="../js/mui.picker.min.js"></script>
<!-- <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> -->
<script type="text/javascript">
mui.init({
//
swipeBack: true,
});
new Vue({
el: "-sharpweather",
data: {
weatherwaring: null,
},
methods: {
//
Get_YJweather: function() {
var _this = this;
mui.ajax("https://segmentfault.com/ask", {
data: {
timefrom: "xxx",
timeto: "xxx"
},
dataType: "json", //json
type: "post", //HTTP
timeout: 50000, //10;
success: function(res) {
_this.weatherwaring = JSON.parse(res);
console.log("" + res);
},
error: function(xhr, type, errorThrown) {
console.log("");
}
});
}
}
});
</script>
</html>
what result do you expect? What is the error message actually seen?
it"s best to make fewer changes to the code. Thank you.