嘗試使用 Vuex、Vue-Router、TypeScript 和 babel 將 Boostrap-Vue 添加到我的專案時,我在瀏覽器中遇到錯誤。
重現
docker run -it --rm -p 8080:8080 node:17.7.2-alpine
yarn global add @vue/cli
vue create my_app
vue add bootstrap-vue
成功后我在borwser中收到此錯誤yarn serve
app.js:953 Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
at eval (config.js?b761:6:1)
at Module../node_modules/bootstrap-vue/esm/utils/config.js (chunk-vendors.js:3415:1)
at __webpack_require__ (app.js:950:33)
at fn (app.js:1205:21)
at eval (props.js:15:65)
at Module../node_modules/bootstrap-vue/esm/utils/props.js (chunk-vendors.js:3668:1)
at __webpack_require__ (app.js:950:33)
at fn (app.js:1205:21)
at eval (model.js:8:64)
at Module../node_modules/bootstrap-vue/esm/utils/model.js (chunk-vendors.js:3591:1)
并嘗試過yarn add bootstrap-vue bootstrap
這是我的main.ts樣子:
import { BootstrapVue, BootstrapVueIcons } from 'bootstrap-vue';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap-vue/dist/bootstrap-vue.css';
import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
const myApp = createApp(App).use(store).use(router);
myApp.use(BootstrapVue);
myApp.use(BootstrapVueIcons);
myApp.mount('#app');
我在瀏覽器中遇到同樣的錯誤
我已經在 node docker 中安裝了 vue 并在 Arch Linux 上通過 yay 安裝了這個。
Vue--版本
@vue/cli 5.0.1
uj5u.com熱心網友回復:
如果您正在使用 Vue.js 版本 3 并希望在新應用程式上使用最新的 Bootstrap 版本,您可能需要查看此執行緒:Using Bootstrap 5 with Vue 3
最新版本的 Bootstrap 不再使用 jquery,因此可以直接使用,無需安裝 bootstrap-vue。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/451592.html
下一篇:動態組件在腳本設定中不起作用
