javascript - window.Vue.use 不是函数
问题描述
我在跑步Laravel 6.20.24
,,,,,,,Laravel Mix v6.0.18
_ npm 7.11.2
_node v15.14.0
WSL2 Ubuntu 20.04.1 LTS
"vue": "^2.6.12",
存档:resources\assets\js\laravel\customer\index.js
我有这个代码
require("../bootstrap");
window.Vue = require("vue");
Vue.component(
"intro-component",
require("./components/IntroComponent.vue").default
);
在:resources\views\customer\welcome.blade.php
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Sample</title>
<meta name="csrf-token" content="{{ csrf_token() }}">
</head>
<body>
<div id="app">
<intro-component
:roles="{{ $roles }}"
:industries="{{ json_encode($industries) }}"
:legal_roles="{{ $legal_roles }}"
redirect-after-save="{{ $setting_url }}">
</intro-component>
</div>
</body>
<script src="{{ mix('js/customer/index.js') }}"></script>
</html>
上webpack.mix.js
.js( "resources/assets/js/laravel/customer/index.js", "public/js/customer/index.js" ).vue()
但是当我访问本地站点时,我得到了这个
index.js?id=c8e33ecef5d0f3eb23d6:66723 Uncaught TypeError: window.Vue.use is not a function
at Module../node_modules/vue-screen/dist/vue-screen.esm.js (index.js?id=c8e33ecef5d0f3eb23d6:66723)
at __webpack_require__ (index.js?id=c8e33ecef5d0f3eb23d6:78757)
at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-5[0].rules[0].use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/laravel/customer/components/IntroComponent.vue?vue&type=script&lang=js& (index.js?id=c8e33ecef5d0f3eb23d6:1853)
at __webpack_require__ (index.js?id=c8e33ecef5d0f3eb23d6:78757)
at Module../resources/assets/js/laravel/customer/components/IntroComponent.vue?vue&type=script&lang=js& (index.js?id=c8e33ecef5d0f3eb23d6:65300)
at __webpack_require__ (index.js?id=c8e33ecef5d0f3eb23d6:78757)
at Module../resources/assets/js/laravel/customer/components/IntroComponent.vue (index.js?id=c8e33ecef5d0f3eb23d6:65262)
at __webpack_require__ (index.js?id=c8e33ecef5d0f3eb23d6:78757)
at Object../resources/assets/js/laravel/customer/index.js (index.js?id=c8e33ecef5d0f3eb23d6:2301)
at __webpack_require__ (index.js?id=c8e33ecef5d0f3eb23d6:78757)
它window.Vue.use is not a function
在编译文件上说。
这有什么问题?
解决方案
问题出在您的 index.js (主文件)中。该文件应如下所示
import Vue from 'vue'
import App from './App'
import Vuex from 'vuex'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
Vue.use(Vuex)
Vue.use(BootstrapVue)
Vue.use(BootstrapVueIcons)
new Vue({
router,
store
render: h => h(App)
}).$mount('#app')
推荐阅读
- reactjs - 如何在 dev 中使用 HTTPS 而不是 HTTP 启动 ReactJS 应用程序
- c - 大量系统负载下的“mmap”性能不佳
- r - 使用 R 将数据写入分区 Parquet 文件
- python - Python代码给出错误但我没有调用?
- angular - cdkDrag 有时会抓取 uderlying 链接元素
- permutation - 如何在visual basic中生成将数组划分为一组子数组的所有可能方式
- python - 为什么在android中的应用程序后不显示?
- java - 如何检查我的 Mac 上是否安装了 Appium?(以 Java 编程方式)
- android - Android将传递函数组合成可组合
- javascript - 致命错误:接近堆限制的无效标记压缩分配失败-脚本上的 JavaScript 堆内存不足