Vue使用axios请求后端数据

引用:axios.js文件

<script src="../../new/js/axios.min.js"></script>

https://unpkg.com/[email protected]/dist/axios.min.jsicon-default.png?t=N4P3https://unpkg.com/[email protected]/dist/axios.min.jsGET:

mounted() {
        axios.get('http://localhost:8080/******/*******', {
            params: {
                	//参数ID
            }
        })
        .then(function (response) {	//请求成功
            console.log(response);
            console.log(response.data.data);

        })
        .catch(function (error) {		//请求失败
            console.log(error);
        });


    },

 POST:

mounted() {
        axios.post('http://localhost:8080/******/*******', {
            params: {
                	//参数ID
            }
        })
        .then(function (response) {	//请求成功
            console.log(response);
            console.log(response.data.data);

        })
        .catch(function (error) {		//请求失败
            console.log(error);
        });


    },

猜你喜欢

转载自blog.csdn.net/qq_45609680/article/details/131004716
今日推荐