如何使用 npm 在 vue.js 中包含 bootstrap-vue?

Abd*_*nik 3 npm webpack vue.js babeljs bootstrap-vue

我正在使用 vue.js、webpack、npm 和 jQuery。现在我想在我的项目中包含框架 bootstrap-vue。我通过 npm遵循了https://bootstrap-vue.js.org/docs的指南,并包含了 bootstrap-vue。在启动 npm 的构建过程时,我在 babel-runtime 中遇到了太多错误,例如:

ERROR in ./node_modules/bootstrap-vue/es/utils/popover.class.js
Module not found: Error: Can't resolve '@babel/runtime/helpers/typeof' in 
'C:\Users\abdul\WebstormProjects\editor\node_modules\
bootstrap-vue\es\utils'
@ ./node_modules/bootstrap-vue/es/utils/popover.class.js 10:38-78
@ ./node_modules/bootstrap-vue/es/directives/popover/popover.js
@ ./node_modules/bootstrap-vue/es/directives/popover/index.js
@ ./node_modules/bootstrap-vue/es/directives/index.js
@ ./node_modules/bootstrap-vue/es/index.js
@ ./src/main.js
Run Code Online (Sandbox Code Playgroud)

主要.js:

import Vue from 'vue'
import App from './App'
import router from './router'
import 'jquery'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

Vue.use(BootstrapVue)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
Run Code Online (Sandbox Code Playgroud)

对于其他 javascript 文件,我也有类似的错误。Popover.class.js 就是其中之一。

我除了使用 bootstrap-vue 成功运行构建。可选:我可以通过其他方式包含 bootstrap-vue。

gia*_*n29 7

安装 vue-cli 3 并添加 bootstrap-vue 作为插件

运行这些命令:

npm install -g @vue/cli

vue create project-name

cd project-name

vue add bootstrap-vue
Run Code Online (Sandbox Code Playgroud)

该插件将自动添加和配置。