I am currently working on integrating the new offcanvas feature of Bootstrap 5 into my Vue app. I have written the code, and after building the app, I am attempting to test it. However, I am facing an issue where the offcanvas menu is not visible. To keep my app lightweight, I have chosen not to load the JavaScript plugin but instead added the 'show' class using a variable binding to toggle the visibility. Can anyone suggest a solution?
<template>
<nav class="navbar navbar-collapse bg-light fixed-top">
<div class="container">
<span class="float-start">
<button class="navbar-toggler" type="button" @click.prevent="showOffcanvasMenu()">
<span class="navbar-toggler-icon"></span>
</button>
</span>
</div>
<div class="offcanvas offcanvas-start" :class="showMenu ? '' : 'show'" tabindex="-1">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="">Offcanvas with backdrop</h5>
<button type="button" class="btn-close text-reset" @click.prevent="showOffcanvasMenu()"></button>
</div>
<div class="offcanvas-body">
<p>.....</p>
</div>
</div>
</nav>
<router-view/>
</template>
<script>
export default {
name: 'App',
data(){
return {
showMenu: false
}
},
methods: {
showOffcanvasMenu(){
this.showMenu ? this.showMenu = false : this.showMenu = true;
}
}
}
</script>
<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>