zoukankan      html  css  js  c++  java
  • vue分享

    如图:

       

      一: 安装share.js

    npm install social-share.js

    二:刚进来初始化

    setTimeout(() => {
            this.setShare();
    }, 0);
    setShare() {
          let random = parseInt(Math.random() * 10000);
          this.urlParam =
            "http://www.xxxxxxx.com/share/index.html?stuWorkid=" +
            data+
            "&schoolcode=" +
            this.$store.state.schoolcode +
            "&random=" +
            random;
          console.log(this.urlParam)
          //分享相关代码
          window._bd_share_config = {
            common: {
              bdText: "我要分享",
              bdDesc: "我也要分享",
              bdUrl: this.urlParam
            },
            share: [
              {
                bdSize: 32
              }
            ]
          };
          console.log(window._bd_share_config)
          var s = document.createElement("script");
          s.type = "text/javascript";
          s.id = "scriptJs";
          s.src =
            "http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=" +
            ~(-new Date() / 36e5);
          console.log(s.src)
          document.body.appendChild(s);
          window._bd_share_main.init();
        }

    三:布局

     <div class="bdsharebuttonbox">
          <img src="../assets/img/weixin.png" data-cmd="weixin"  title="分享到微信"/>
          <img src="../assets/img/weibo.png"  data-cmd="tsina"  title="分享到新浪微博"/>
          <img src="../assets/img/gengduo.png" data-cmd="more"  title="更多"/>
     </div>

                                                                                                                                          ----------END

  • 相关阅读:
    C#中一行代码实现18位数字时间戳转换为DateTime
    Java,Python,前端,Linux,公众号等5T编程资源整理免费下载
    Winform中使用FastReport的DesignReport时怎样给通过代码Table添加数据
    一、渐变边框
    一、Dev单元格
    一、Dev
    一、
    三、数据-1
    三、接口数据格式-2
    二、GitLab使用
  • 原文地址:https://www.cnblogs.com/liujiajiablog/p/10893422.html
Copyright © 2011-2022 走看看