寒光博客

vue+axios解析 json
vue json 解析(get) { id: 1, name: "李四", age: 11, email: "b...
扫描右侧二维码阅读全文
01
2021/07

vue+axios解析 json

vue json 解析(get)

{
id: 1,
name: "李四",
age: 11,
email: "b@qq.com"
},
    var app_user_list = new Vue({
            el: '#app_userList',
            data: {
                userList: {}
            },
            methods: {
                getUserList: function () {
                    var that = this;
                    axios.get("http://localhost:8081/user").then(function (response) {
                        console.log(response.data);
                        that.userList = response.data;
                    }, function (err) {
                        console.log(err);
                    })
                }
            }
        }
    )

<div id="app_userList">
    <div class="table">
        <div class="tr bg-w">
            <div class="th">id</div>
            <div class="th">name</div>
            <div class="th ">age</div>
            <div class="th ">email</div>
            <div class="th ">edit</div>
        </div>
        <block v-for="user in userList">
            <div class="tr bg-g" v-if="user.id % 2 == 0">
                <div class="td">{{user.id}}</div>
                <div class="td">{{user.name}}</div>
                <div class="td">{{user.age}}</div>
                <div class="td">{{user.email}}</div>
                <div class="td" id="edit">修改|编辑</div>
            </div>
            <div class="tr" v-else>
                <div class="td">{{user.id}}</div>
                <div class="td">{{user.name}}</div>
                <div class="td">{{user.age}}</div>
                <div class="td">{{user.email}}</div>
                <div class="td" id="edit">修改|编辑</div>
            </div>
        </block>
    </div>
    <button bindtap="addUser" type="primary" @click="getUserList">获取信息</button>
</div>
本文作者:Author:     文章标题:vue+axios解析 json
本文地址:https://dxoca.cn/skill/392.html       百度已收录
版权说明:若无注明,本文皆为“Dxoca's blog (寒光博客)”原创,转载请保留文章出处。
Last modification:July 1st, 2021 at 06:11 pm
如果觉得我的文章对你有用,请随意赞赏

Leave a Comment