我正在尝试将 bootstrap 5 的新 offcanvas 组件集成到我的 vue 应用程序中。我有这段代码,在构建应用程序后,我想测试它,但我看不到 offcanvas 菜单。我没有加载 js 插件来维护我的应用程序灯,我正在使用将绑定所需类的变量添加显示类。我该如何解决?
<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>
<!-- <div class="container-fluid bg-light p-0" v-show="isLoading">
<div class="row">
<div class="col-12 text-center">
<div class="spinner-grow text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div> -->
<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;
//color: #2c3e50;
}
</style>