Vue中用axios进行数据请求

一、vue中可以用axios来做接口
二、使用步骤
(1)axios的安装

npm install axios
--save

(2)在main.js中引入

 import axios from 'axios'

在这里插入图片描述
(3)在vue文件中也要引入

<script>
import axios from 'axios';
mounted: function() {
    
    
 axios
    .get('url接口地址&limit=5&offset=0&order=desc')			
    .then(response => (this.list1 =response.data.rows))			
    .catch(function(error) {
    
    				
       // 请求失败处理	
       console.log(error);			
 });
}
</script>

猜你喜欢

转载自blog.csdn.net/huang_jimei/article/details/107929396
今日推荐