Javascript 更新Vue会出现错误窗口。Vue.use不是一个函数
将Javascript 更新Vue会出现错误窗口。Vue.use不是一个函数,javascript,vuejs2,Javascript,Vuejs2,将Vue从v1.0.26更新到v2.4.4后,我得到一个错误: window.Vue.use is not a function 这是我的条目js bootstrap.js: window._ = require('lodash'); /** * We'll load jQuery and the Bootstrap jQuery plugin which provides support * for JavaScript based Bootstrap features such as
Vue
从v1.0.26
更新到v2.4.4
后,我得到一个错误:
window.Vue.use is not a function
这是我的条目js bootstrap.js:
window._ = require('lodash');
/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/
//window.$ = window.jQuery = require('jquery');
require('bootstrap');
/**
* Vue is a modern JavaScript library for building interactive web interfaces
* using reactive data binding and reusable components. Vue's API is clean
* and simple, leaving you to focus on building your next great project.
*/
window.Vue = require('vue');
require('vue-resource');
/**
* We'll register a HTTP interceptor to attach the "CSRF" header to each of
* the outgoing requests issued by this application. The CSRF middleware
* included with Laravel will automatically verify the header's value.
*/
Vue.http.interceptors.push((request, next) => {
request.headers['X-CSRF-TOKEN'] = Laravel.csrfToken;
next();
});
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
// import Echo from "laravel-echo"
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: 'your-pusher-key'
// });
和app.js:
/**
* First we will load all of this project's JavaScript dependencies which
* include Vue and Vue Resource. This gives a great starting point for
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
require('./slider');
require('./search-form');
require('./scroll-spy');
require('./smooth-scroll');
require('./autocomplete');
var VueResource = require('vue-resource');
/**
* Next, we will create a fresh Vue application instance and attach it to
* the body of the page. From here, you may begin adding components to
* the application, or feel free to tweak this setup for your needs.
*/
Vue.component('video-player', require('./components/VideoPlayer.vue'));
Vue.component('videos', require('./components/Videos.vue'));
Vue.component('single-video', require('./components/Video.vue'));
Vue.component('players', require('./components/Players.vue'));
Vue.component('pages', require('./components/Pages.vue'));
Vue.component('videos-counter', require('./components/VideosCounter.vue'));
Vue.component('players-counter', require('./components/PlayersCounter.vue'));
Vue.component('player', require('./components/Player.vue'));
Vue.component('player-card', require('./components/PlayerCard.vue'));
Vue.component('player-info', require('./components/PlayerInfo.vue'));
Vue.component('player-stats', require('./components/PlayerStats.vue'));
Vue.component('player-videos', require('./components/PlayerVideos.vue'));
Vue.component('masked-input', require('./components/MaskedInput.vue'));
Vue.use(VueResource);
const app = new Vue({
el: 'body',
data: window.videoApp
});
我试着四处搜索,但找不到任何关于的信息,我如何解决这个问题
这是webpack.config.js:
{
module: {
noParse: [
/node_modules[\\/]video\.js/
]
}
}
我运行gulpfile来完成构建任务:
const elixir = require('laravel-elixir');
require('laravel-elixir-vue');
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic Gulp tasks
| for your Laravel application. By default, we are compiling the Sass
| file for our application, as well as publishing vendor resources.
|
*/
elixir(mix => {
mix.copy('resources/assets/js', 'public/js');
//mix.copy('resources/assets/css', 'public/css');
mix.sass('app.scss')
.sass('admin.scss', 'public/css/admin.css')
.sass('new-app.scss', 'public/css/new-app.css')
.webpack('app.js')
.webpack('admin.js')
});
请为
webpack.config.js
尝试此配置
resolve: {
alias: {
vue: 'vue/dist/vue.js'
}
}
(感谢@yyx990803!)
或者。。。控制台日志(Vue)的结果是什么
我想应该是{default:function Vue()…}
(您可以更改导入Vue库的方式,或添加。默认值
但是这个解决方法不起作用。什么是console.log(window.Vue)
打印出来的?你使用webpack吗?你能添加它的配置吗?我已经在问题中添加了配置