为了账号安全,请及时绑定邮箱和手机立即绑定

Vue.js - Bootstrap Vue Popover 解释 HTML

Vue.js - Bootstrap Vue Popover 解释 HTML

波斯汪 2023-03-18 17:37:18

我希望弹出窗口在单击时显示一个或多个超链接。我能够通过使用v-html参数让其他 Bootstrap 元素来解释 HTML,尽管它在这种情况下不起作用。


这是我的代码:


<template>

  <div>

    <b-button

      :id="popover"

      size="sm"

    >

      Button

    </b-button>

    <b-popover

      :target="popover"

      triggers="focus"

      v-html="actions"

    >

      {{ actions }}

    </b-popover>

  </div>

</template>


<script>

  export default {

    computed: {

      actions() {

        return [

          `<a href="www.google.com">Google</a><br>`,

          `<a href="www.youtube.com">Youtube</a><br>`

        ].join('')

      }

    }

  }

</script>


查看完整描述

1 回答

?
慕标5832272

TA贡献1729条经验 获得超4个赞

删除绑定登录:,target然后id更改它们以popover1创建一个嵌套的 div,其中包含v-html具有 as value 的指令actions:


<template>

  <div>

    <b-button

      id="popover1"

      size="sm"

    >

      Button

    </b-button>

    <b-popover

      target="popover1"

      triggers="focus"

    

    >

    <div v-html="actions"></div>

    </b-popover>

  </div>

</template>


<script>

  export default {

    computed: {

      actions() {

        return [

          `<a href="www.google.com">Google</a><br>`,

          `<a href="www.youtube.com">Youtube</a><br>`

        ].join('')

      }

    }

  }

</script>

如果id和target属性绑定到属性,则应保留绑定符号。


查看完整回答
反对 回复 2天前
  • 1 回答
  • 0 关注
  • 6 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信