简体   繁体   English

将 Popper 合并到 Vue/Bootstrap 项目中

[英]Incorporating Popper into a Vue/Bootstrap project

I'm trying to get Popover to work with my Bootstrap 5 theme that I've split into Vue components.我正在尝试让 Popover 与我已拆分为 Vue 组件的 Bootstrap 5 主题一起使用。 The Bootstrap css is working fine, but I'm not sure the js is, and I can't seem to get the Popover components to work so I'm pretty sure I'm not importing or enabling something properly. Bootstrap css 工作正常,但我不确定 js 是否正常,而且我似乎无法让 Popover 组件工作,所以我很确定我没有正确导入或启用某些内容。

This is as close as I think I've gotten in my main.js , but this code doesn't work:这与我认为我在main.js中得到的一样接近,但这段代码不起作用:

import { createApp } from 'vue'
import App from './App.vue'

import { Popover } from 'bootstrap';
import 'bootstrap/scss/bootstrap.scss';

var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-toggle="popover"]'))
popoverTriggerList.map(function (popoverTriggerEl) {
    return new Popover(popoverTriggerEl)
})

createApp(App).use(store).use(router).mount('#app')

I get why this wouldn't work with Vue, but I'm not sure what else to try.我明白为什么这不适用于 Vue,但我不确定还能尝试什么。

I installed Popper via npm install @popperjs/core , and I tried importing that as well but I couldn't get that to work either.我通过npm install @popperjs/core安装了 Popper,我也尝试导入它,但我也无法让它工作。

I'm using Bootstrap 5 and Vue 3, and I'm not sure what to try next so any help would be appreciated.我正在使用 Bootstrap 5 和 Vue 3,但我不确定接下来要尝试什么,因此我们将不胜感激。

Turns out I was having a different problem, this is sufficient结果我遇到了不同的问题,这就足够了

import 'bootstrap';
import 'bootstrap/scss/bootstrap.scss';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM