Vue dynamically changes the src of img according to the key value value returned by ajax

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.

Jan.13,2022

the best solution in your way is, of course, to return the url of the image directly in the background. This is the most convenient and fastest solution.
of course, it's not impossible if you want to do it this way. You can create a new file in which all the pictures you want to use will be imported by require first.
and then form a corresponding map for weather conditions--> key-value pairs such as weather pictures. Then call map.get ('weather name') directly where you need to call (in the src of img)

add:
you can create a new function in which you can directly use switch or if else to determine the weather name, and return the image address corresponding to the weather
, and then write this function

in the src.
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);
                        _this.weatherwaring.forEach(function(item){
                            //ALARMNAME
                            item.ALARMNAME = _this.getPic(item.ALARMNAME);
                        })
                        console.log('' + res);
                    },
                    error: function(xhr, type, errorThrown) {
                        console.log('');
                    }
                });
            },
            //
            getPic: function(text){
                var _this = this;
                var imgUrl = ''
                switch(text) {
                    case '':
                        imgUrl = '';
                        break;
                    case '':
                        imgUrl = '';
                        break;
                }
                return imgUrl
            }
        }
    });
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35c2e-2bfb2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35c2e-2bfb2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?