Home > Software design >  Does vuejs project can import bootstrap.min.js file?
Does vuejs project can import bootstrap.min.js file?

Time:05-25

I have a project in vuejs which bootstrap is already installed. I am using html, css project and converting into vuejs which bootstrap classes are used. However, dropdown bootstrap classes are not working for example, the below classes are not adding Show class when its getting clicked and normal html file is showing show class.

dropdown-toggle dropdown-menu

I have

"bootstrap": "^5.1.3",
"bootstrap-vue": "^2.22.0",
"@popperjs/core": "^2.11.5",

Can someone please suggest something?

Thanks

CodePudding user response:

Use show or shown

The in Bootstrap-Vue doesn't have a click event, but it does emit a show event shortly before the dropdown appears, including when it's clicked. It immediately follows.

<b-nav-item-dropdown @show="doSomething">

Your code:

<b-nav-item-dropdown text="nav_title" @show="doSomething">
    <b-dropdown-item href="#">
        a
    </b-dropdown-item>
    <b-dropdown-item href="#">
        a
    </b-dropdown-item>
</b-nav-item-dropdown>
methods: {
  doSomething() {
    console.log('shown');
  }
}

(You didn't find information for it on Vue's site because they didn't make the library.)

  • Related