【发布时间】:2019-04-11 02:13:35
【问题描述】:
我正在使用 Vue 3 开发一个项目。我尝试添加 bootstrap-material-datetimepicker 进入我的项目。这就是我在我的 Vue 组件文件中导入它的方式。
<template>
<div>
<!-- -->
</div>
</template>
<script>
// ..
import 'bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker.js'
import 'bootstrap-material-datetimepicker/css/bootstrap-material-datetimepicker.css'
// ..
</script>
我在尝试运行它时遇到错误。从错误中,我可以看出在我的应用程序中未检测到 jquery。这很奇怪,因为我相信我已将 jquery 插件定义添加到 vue.config.js 文件中。
const webpack = require('webpack')
module.exports = {
baseUrl: '/public/',
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
jQuery: 'jquery'
})
]
}
在下面的浏览器控制台上是我得到的错误:
vue-router.esm.js?8c4f:1905 ReferenceError: jQuery is not defined 在 eval (bootstrap-material-datetimepicker.js?5260:1295) 在 Object../node_modules/bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker.js (vendors~PublicSignUp.js:76) 在 webpack_require (app.js:768) 在 fn (app.js:131) 在 eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js ?!./src/pages/public/SignUp.vue?vue&type=script&lang=js&:6) 在 Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules /vue-loader/lib/index.js?!./src/pages/public/SignUp.vue?vue&type=script&lang=js& (PublicSignUp.js:11) 在 webpack_require (app.js:768) 在 fn (app.js:131) 在评估 (SignUp.vue?8585:1) 在 Module../src/pages/public/SignUp.vue?vue&type=script&lang=js& (PublicSignUp.js:80)
我应该怎么做才能解决这个问题?
【问题讨论】:
标签: vue.js