superman66 / vue2.x-douban

Vue2.0实现简易豆瓣电影webApp
http://superman66.github.io/vue2.x-douban/dist/#/
798 stars 292 forks source link

#bug #3

Closed BestDingSheng closed 7 years ago

BestDingSheng commented 7 years ago

项目打包后 豆瓣电影的api 地址就不对了 ![Uploading image.png…]() 怎么解决

superman66 commented 7 years ago

api代理只能在开发环境下使用。 项目打包后,要想使用豆瓣的api,你得自己搭个后端的API转发,才能解决跨域问题。

BestDingSheng commented 7 years ago

不会后端 ,大神有什么解决方案么。 axiso 有jsonp之类的跨域请求么

superman66 commented 7 years ago

https://github.com/mzabriskie/axios/issues/342 官方说了,axios并不支持jsonp。 我改天我再写个node,转发api的demo。

BestDingSheng commented 7 years ago

哈哈哈 谢谢大神 能否加个QQ或者微信 不懂的可以请教下您

superman66 commented 7 years ago

qq 673318522

zhoucumt commented 7 years ago

首先感谢楼主的分享,然后请教两个问题,还没来得及仔细研究, 1.为啥页面中审查DOM,发现id="app"的div不见了?是不是打包之后插入的地方有问题,导致直接覆盖了,然后id为app的div直接就消失了 2.页面中审查元素发现style标签很多而且有几个都是空内容,留下了很多空白,如下图: image @superman66

superman66 commented 7 years ago
  1. id元素不见 我觉得是因为webpack 在dev环境下,用了new HtmlWebpackPlugin而产生的。具体的原因有待研究。
  2. 空白style标签 在dev环境下,vue-loader在编译.vue文件的时候,只要遇到<style>标签,便会将其编译成<style></style>内嵌到HTML中的header。出现空白是因为有几个vue单文件的<style></style>内是为空的,所以就会产生空白。我把vue单文件中空白的style都去掉后,这个问题便解决了。