首先是参考了博客,下载百度分享的静态代码 static
链接为:https://www.cnblogs.com/mmzuo-798/p/6434576.html
后来在nginx的 nginx.conf文件中添加
location ^~ /static/ {
root E:/Workspaces/Idea15/demo/web/WEB-INF;
}
这段代码在windows中测试有用,但是在linux中改下路径没用。
最后的解决办法,没有深究nginx的问题,而是一种更简单的通用方法,单独部署静态文件 static
1、在代码调用的时候写成
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":["mshare","weixin","sqq","tsina","qzone","tqq","tieba","youdao","ty","evernotecn","fbook","copy","print"],"bdPic":"","bdStyle":"0","bdSize":"16"},"slide":{"type":"slide","bdImg":"1","bdPos":"left","bdTop":"100"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='../static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
2、在tomcat的 webapps目录下部署 static文件
tomcat是可以直接部署静态文件的
这样就可以直接访问了,如下:https://jiashubing.cn/static/api/js/share.js