$ git clone "https://github.com/LY0528/vue-zhihu-daily"
$ cd vue-zhihu-daily
$ npm install
$ npm run dev
vue/vue-cli/vue-router2/axios/mint-ui
首先谢谢izzyleung提供的api,看这里
1.api接口不支持jsonp跨域请求,我于是google了一番,发现可以使用vue-cli自带的config目录里的index.js文件中的proxyTable文件配置进行解决,配置如下:
proxyTable: {
'/api': {
target: 'http://news-at.zhihu.com',
changeOrigin: true,
pathRewrite: {
'^/api': '/api/4'
}
}
}
此时请求api/xxx将会代理成http://news-at.zhihu.com/api/4/xxx,当然
这种方法只适合开发环境
2.api在使用的过程中图片加载会出现403错误代码,解决的办法在这里