首页 > 解决方案 > 带有 laravel 的 bootstrap-vue.js 未知自定义元素:错误

问题描述

我是 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
             }

     },

}

标签: javascriptlaravelvue.jsbootstrap-vue

解决方案


您必须像在组件注册中一样注册组件

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

components: { BAlert }

由于所有的html标签都被camelcase变成了虚线BAlert='<b-alert>'

或者你也可以使用

components: { 'b-alert': BAlert }

推荐阅读