xyy-vue icon indicating copy to clipboard operation
xyy-vue copied to clipboard

资源请求问题

Open zerofront opened this issue 7 years ago • 4 comments

系统:win7

作为一个学生,看到代码学习了很多,非常感谢,能否问问一些问题 default 这个该如何处理?看了一圈issues好多人都有这个问题,npm run dev无法正常加载 点开无法加载的地址,浏览器显示地址是http://localhost:8080/你的接口地址/api/travelList#/

在fetch文件夹的api.js中 // axios 配置 axios.defaults.timeout = 5000; axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'; axios.defaults.baseURL = '你的接口地址';

在config的index.js文件中。 dev: { env: require('./dev.env'), port: 8080, autoOpenBrowser: true, assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: {}, // CSS Sourcemaps off by default because relative paths are "buggy" // with this option, according to the CSS-Loader README // (https://github.com/webpack/css-loader#sourcemaps) // In our experience, they generally work as expected, // just be aware of this issue when enabling this option. cssSourceMap: false }

请问该如何更改才能正确请求资源,对node.js不是很懂哈 default index

zerofront avatar Apr 26 '17 01:04 zerofront

因为那个后台我用的node+leancloud,一开始我把接口公开,然后我的后台就炸了(服务器比较渣),还有leancloud是收费的,如果这么多人用的话,承受不起,望见谅,我也还是学生

hzzly avatar Apr 26 '17 05:04 hzzly

你node用的不是leancloud的云引擎?

lileltp avatar Apr 27 '17 09:04 lileltp

前后端分离,需要配置代理,https://vuejs-templates.github.io/webpack/proxy.html

// config/index.js module.exports = { // ... dev: { proxyTable: { // proxy all requests starting with /api to jsonplaceholder '/api': { target: 'http://jsonplaceholder.typicode.com', changeOrigin: true, pathRewrite: { '^/api': '' } } } } } The above example will proxy the request /api/posts/1 to http://jsonplaceholder.typicode.com/posts/1.

TonyDalian avatar Aug 22 '17 01:08 TonyDalian

我做了后台 有需要的可以联系我 QQ1023566696 qq 20180417150226

mstianyu avatar Apr 17 '18 07:04 mstianyu