用VUE仿链家网的时候,运行文件时出现GET http://localhost:8080/api 404 (Not Found)。
dev: { // Paths assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: { '/api': { target: 'http://47.110.132.127:6789/city/get/data', changeOrigin: true, pathRewrite: { '^/api': '/data' } } }, getPageInfo () { /// 地址为后台数据地址为后台数据地址为后台数据地址为后台数据地址为后台数据 axios.get('/api', { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }) .then(function (res) { res = res.data if (res.ret && res.data) { const data = res.data this.total = data.total this.pagingVolume = data.pagingVolume this.current = data.current this.contentList = data.contentList /// 前后名字一样 } }) /// 先接受json文件,然后返回函数 .catch(function (error) { console.log(error) }) }
pardon110