1.安装 axios
vue add axios
2.项目根目录下新建 vue.config.js
// vue.config.js
module.exports = {
    devServer: {
        port: 端口号,
        proxy: {
            '/apis': {
                target: 'https://movie.douban.com/',  // target host
                ws: true,  // proxy websockets 
                changeOrigin: true,  // needed for virtual hosted sites
                pathRewrite: {
                    '^/apis': ''  // rewrite path
                }
            },
        }
    }
};
3. 重启服务npm run serve
4. *.vue 文件中请求实例
this.axios.get('/apis/ithil_j/activity/movie_annual2017').then(res => {
	console.log(res.data)
}, res => {
    console.info('调用失败');
})
Logo

前往低代码交流专区

更多推荐