【问题标题】:bootstrap-vue.js with laravel Unknown custom element: <b-alert> error带有 laravel 未知自定义元素的 bootstrap-vue.js:<b-alert> 错误
【发布时间】:2018-12-26 20:32:26
【问题描述】:

我是 Vuejs 新手,我收到错误未知自定义元素 -

如何注册自定义元素 - b-alert。我认为这个元素来自 bootstrapVue。

<template>
<div>
 <b-alert show>Default Alert</b-alert>



  </div> 
   </template>

    <script>
   export default {
    data () {
            return {
                 dismissSecs: 10,
                 dismissCountDown: 0,
                 showDismissibleAlert: false
            }
    },
                  methods: {
             countDownChanged (dismissCountDown) {
                     this.dismissCountDown = dismissCountDown
             },
             showAlert () {
                     this.dismissCountDown = this.dismissSecs
             }

     },

}

【问题讨论】:

    标签: javascript laravel vue.js bootstrap-vue


    【解决方案1】:

    您必须将组件注册为Component registration

    import { Alert } from 'bootstrap-vue/es/components';
    
    components: { BAlert }
    

    由于所有的html标签都变成了驼峰式的虚线BAlert = '&lt;b-alert&gt;'

    或者你也可以使用

    components: { 'b-alert': BAlert }
    

    【讨论】:

    • 我在文件中添加了组件:{ 'b-alert': BAlert },现在我得到一个错误 BAlert is not defined
    • 您是否使用vue-cli 来设置您的项目,您是否使用了npm install bootstrap-vue
    • BAlert 未定义,因为您导入了Alert 而不是BAlert
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-11
    • 2018-12-23
    • 2018-11-06
    • 2020-04-05
    • 2020-02-03
    • 2019-02-03
    • 2020-12-03
    相关资源
    最近更新 更多