vue 使用 axios

  1. 命令行里安装 npm install --save vue-axios
  1. man.js 里
    import axios from 'axios'
    
    import VueAxios from 'vue-axios'
    
    Vue.use(VueAxios,axios);
  1. 在组件中直接就可以使用
getNewsList(){

      this.axios.get('api/getNewsList')

            .then((response)=>

                    {

                        this.newsList=response.data.data;    

                     })

                    .catch((response)=>{console.log(response);      }

      )},

  1. 更多方法点击链接
    https://blog.csdn.net/connie_0217/article/details/78703112

你可能感兴趣的:(vue 使用 axios)