thymeleaf+百度分享组件的冲突

/ 默认分类 / 4 条评论 / 3459浏览

第一坑:

org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression:
"getElementsByTagName('head'[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new
 Date()/36e5" (template: "themes/default/post" - line 33, col 179)

这个问题是with与thymeleaf 冲突 百度复制过来的原版: with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];

改写为:

(document.getElementsByTagName('head')[0] || document.body).appendChild(document.createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5);

完美解决第一坑。

第二坑:

由百度帮你生成的微信二维码 无法被扫描识别

原因简直无解 眼神不行真的无法解决这个神一样的百度bug 是因为二维码被拉伸了!

百度的工程师 加了一个width:185px的element style。写死的 恩!写死的!作为一个百度的组件居然写死。。。感觉这个大神可能是外包的吧。

with(document)0

还用0来当变量名称,沃日你妈卖批,我一个后端被这个大神搞蒙逼了一天!

解决方案: 在header 添加:

<style>
    #bdshare_weixin_qrcode_dialog_qr table {
        width: auto !important;
    }
</style>

解决。

  1. 1

    牛逼!!!!!!!!!!!!!!!

  2. NB!感谢兄弟,我也趟雷了,MD

  3. 搞了老子半天,原来和Thymleaf冲突