您的位置:首页 > 其它

web项目实战(一)— —开发中问题收集

2016-04-25 18:56 453 查看
一、让百度地图支持https协议

  当前页面是https协议, 但是百度异步加载API给的是http协议的链接,所以会出现如下:

Mixed Content: The page at ‘https://….’ was loaded over HTTPS, but requested an insecure script ‘http://api.map.baidu.com/api?v=1.4&callback=initializeBaidu’. This request has been blocked; the content must be served over HTTPS.

解决方案参考链接:

  百度Javascript Api主页:http://lbsyun.baidu.com/index.php?title=jspopular/guide/introduction

 1. 如果使用JavaScript API ,需要加一个特殊字段 (s=1):

https://api.map.baidu.com/api?v=2.0&ak=你的密钥& s=1;

【注意】仅JavaScript API V2.0 版本支持https,其他JavaScript API版本均不支持

  ==>https协议的异步加载的url改为https://api.map.baidu.com/api?v=2.0&ak=your_appkey&s=1&callback=initialize

 2、如果是在浏览器端访问,可以设置浏览器加载’不安全的脚本’也可正常加载百度地图

二、webpack打包后打开服务器报 can’t find favicon.icon,找不到网页小图标

1、require my favicon in my main App.js entry file

require(‘../assets/images/favicon.ico’)

或者11、在img在require加载

<img src={require('../../images/pluralsight-logo.png')} />


2、Added a loader configuration that does not scramble the image file names in the build task (per this thread webpack/webpack#1336 (comment))

{
test: /\.jpe?g$|\.ico$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/,
loader: 'file-loader?name=[name].[ext]'  // <-- retain original file name
}


三、webpack构建后的output输出js为空

<script />//错误,script不能自闭合
<script type="text/javascript" src="./bundle.js"></script>


参考:https://github.com/coryhouse/react-slingshot/issues/128
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: