【问题标题】:Do not show up the bootstrap icon even import BIcon即使导入 BIcon 也不显示引导图标
【发布时间】:2020-05-19 04:06:32
【问题描述】:

在我的 nuxt.js bootstrap-vue 项目中:

我跟随 github 使用 bootstrap 图标: the link

我的代码:

      <b-icon variant="success" icon="arrow-up"></b-icon>
      <b-icon variant="success" icon="alert-triangle"></b-icon>

      <b-icon icon="alert-circle-fill" variant="success"></b-icon>

      <h2 class="group_title">Anime Wallpapers</h2>

...

<script>

  import { BIcon, BIconArrowUp } from 'bootstrap-vue'

  export default{
    data(){
      return {
        msg: 'hello vue'
      }
    },
    components: {
      BIcon
    }
  }
</script>

但是没有显示出来:

【问题讨论】:

    标签: vue.js icons nuxt.js bootstrap-vue


    【解决方案1】:

    您导入了BIcon 并注册了它,但您没有注册请求的单个图标。

    试试这个:

          <b-icon variant="success" icon="arrow-up"></b-icon>
    
          <b-icon icon="alert-circle-fill" variant="success"></b-icon>
    
          <h2 class="group_title">Anime Wallpapers</h2>
    
    ...
    
    <script>
    
      import { BIcon, BIconArrowUp } from 'bootstrap-vue'
    
      export default{
        data(){
          return {
            msg: 'hello vue'
          }
        },
        components: {
          BIcon,
          BIconArrowUp // <- The icon needs to be registered with your page/app
        }
      }
    </script>
    

    请参阅提到您需要导入单个图标的文档:https://bootstrap-vue.org/docs/icons#usage

    【讨论】:

    • 我有类似的问题,但正在全局导入和注册各个图标组件。 import { BIcon, BIconPersonCircle } from 'bootstrap-vue'Vue.component(BIcon)Vue.component(BIconPersonCircle)。在模板中,&lt;b-icon icon="person-circle"&gt;&lt;/b-icon&gt; 但未呈现图标。知道为什么吗?谢谢
    • 找到了我的问题的答案。以防万一其他人有同样的情况。在全局注册 Vue.component("BIcon", BIcon) 等单个图标时,您必须提供名称。
    猜你喜欢
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多