I am trying to use Bootstrap 5's "collapse" component on a button, but I am unsure how to actually use it with VueJS2
I have a single file component like so:
<template>
section:
<button
class="btn btn-danger"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapseExample"
aria-expanded="false"
aria-controls="collapseExample"
>
Mark As Rejected
</button>
<div class="collapse" id="collapseExample">
<div class="card card-body">
Some placeholder content for the collapse component. This panel is
hidden by default but revealed when the user activates the
relevant trigger.
</div>
</div>
<script>
section:
<script>
import Collapse from 'bootstrap/js/dist/collapse'
export default {
...
methods: {
// how to manually enable the collapse via JavaScript???
}
}
...
</script>
The Bootstrap docs had an example of using vanilla JavaScript...but how to do it with VueJS?
Bootstrap 5 Collapse native JavaScript example:
var collapseElementList = [].slice.call(document.querySelectorAll('.collapse'))
var collapseList = collapseElementList.map(function (collapseEl) {
return new bootstrap.Collapse(collapseEl)
})