最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - [Vue warn]: Failed to resolve directive: b-popover - Stack Overflow

programmeradmin4浏览0评论
<template>
  <div>
    <div class="text-center my-3">
      <b-button
        v-b-popover.hover="'I am popover content!'"
        title="Popover Title"
        >Hover Me</b-button
      >
    </div>
  </div>
</template>

<script>
import { VBPopover } from "bootstrap-vue";
export default{
  directives: {
    VBPopover
  },
}
<script>

So I am not sure why I am getting this warning. If I replace v-b-popover.hover with b-popover.hover this warning goes away but the functionality is not there.

Basically trying to implement the popover directive from the docs:

<template>
  <div>
    <div class="text-center my-3">
      <b-button
        v-b-popover.hover="'I am popover content!'"
        title="Popover Title"
        >Hover Me</b-button
      >
    </div>
  </div>
</template>

<script>
import { VBPopover } from "bootstrap-vue";
export default{
  directives: {
    VBPopover
  },
}
<script>

So I am not sure why I am getting this warning. If I replace v-b-popover.hover with b-popover.hover this warning goes away but the functionality is not there.

Basically trying to implement the popover directive from the docs: https://bootstrap-vue/docs/directives/popover

Share Improve this question edited Jun 29, 2020 at 4:01 Phil 165k25 gold badges262 silver badges267 bronze badges asked Jun 29, 2020 at 3:44 Sir lethianSir lethian 431 gold badge2 silver badges6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Directive IDs are automatically prefixed with v-. You should probably explicitly set the directive ID as indicated here

directives: {
  'b-popover': VBPopover
}

What was happening is that

directives: {
  VBPopover 
}

is the same as

directives: {
  VBPopover: VBPopover
}

and the name VBPopover was transformed to v-b-popover and then had the automatic prefix applied to bee v-v-b-popover. So you could use that in your template but to me, it looks pretty silly.

Directives don't behave like ponents when it es to their names. Directive names are always transformed to kebab-case and prefix with v-.

发布评论

评论列表(0)

  1. 暂无评论