vue项目引入百度分享组件,报with错误

图片描述1、手机端网页项目是用vue做的。
2、找到是百度社会化分享插件
3、引入报错
4、请问怎么解决

引用文字
<template>
  <div class="list">
     <!--<div class="item" v-for="item in 10" :key="item">商品详情{{item}}{{$store.state.num}}</div>-->
     <div class="bdsharebuttonbox">
        <a href="#" class="bds_more" data-cmd="more"></a>
        <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
        <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
        <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
        <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
        <a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a>
        <a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
      </div>

  </div>
</template>
<script>
export default {
  data(){
    return {
      list:[]
    }
  },
  methods:{
    initFn(){
        window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};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)];
    },
  },
  mounted(){
    this.initFn() 
  }
}
</script>
阅读 2.7k
1 个回答

去掉with

        window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};document.getElementsByTagName('head')[0].appendChild(document.createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题