element table表格 怎么样 循环遍历某个div?

发布于 2022-09-11 15:20:41 字数 1126 浏览 23 评论 0

这样一个表格想出现每个按钮 ‘微信二维码’ 的下面出现一个二维码,按当前注释div写法 当调用插件方法的时候所有的二维码都跑到第一个按钮的下面了,怎么样实现一个按钮下面一个?

     <el-table-column label="商户前台" width="200%">
        <template slot-scope="scope">
          <el-popover
            placement="bottom"
            title=""
            trigger="hover">
            <!--<div v-show="flag" id="qrcode" ref="qrcode" ></div>-->
            <div slot="reference" class="name-wrapper" style="display: inline-block">
              <el-button size="small" type="danger" style="margin-top:10px" class="chat">
                <a style="color: #fff;" @mouseover="selectStyle" @mouseout="selectOut">微信二维码</a>
              </el-button>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      

调用插件二维码方法

      let qrcode = new QRCode('qrcode',{
          width: 100,    // 设置宽度,单位像素
          height: 100,   // 设置高度,单位像素
          text: 'http://www.cpglib.com/wx/index?shopId='+scope.row.shopId,   // 生成二维码图片
        })
  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生路 2022-09-18 15:20:41

谢邀~
你这样的写法循环出来的,只有一个id呀。
方案一、一次性全部生成好:

<div v-show="flag" :id="`qrcode${scope.$index}`" ref="qrcode" ></div>

然后去循环出

// for循环
let qrcode = new QRCode(`qrcode${index}`,{
  width: 100,    // 设置宽度,单位像素
  height: 100,   // 设置高度,单位像素
  text: 'http://www.cpglib.com/wx/index?shopId='+scope.row.shopId,   // 生成二维码图片
});

方案二:
也可以hover时去生成这个二维码。
selectStyle(index){

let qrcode = new QRCode(`qrcode${index}`,{
  width: 100,    // 设置宽度,单位像素
  height: 100,   // 设置高度,单位像素
  text: 'http://www.cpglib.com/wx/index?shopId='+scope.row.shopId,   // 生成二维码图片
});

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文