在 运行 "npm run watch" 之后出现以下错误 "You may need an appropriate loader to handle this file type, e."
Getting the following error "You may need an appropriate loader to handle this file type, e." after running the "npm run watch"
Geek's 需要很少的帮助,我们将不胜感激任何建议或提示。
问题是我正在尝试在 Laravel 上安装 Vue。但是在安装 Vue 路由器之后,我决定使用“npm 运行 watch”编译所有内容,但我在控制台上收到以下错误:
注意* 在 运行 执行“npm 运行 watch”命令之前,Vue 已被浏览器(“Vue Dev Tool”)检测到,但现在无法检测到,我不知道我在哪里做了错误:(.
ERROR in ./resources/js/components/ExampleComponent.Vue 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <template>
| <div class="container">
| <div class="row justify-content-center">
webpack compiled with 1 error
APP.js代码
require('./bootstrap');
import router from "./routes";
import VueRouter from "vue-router";
import Vue from "vue";
window.Vue = require('vue').default;
Vue.component(
'example-component',
require('./components/ExampleComponent.vue').default);
Vue.use(VueRouter);
const app = new Vue({
el: '#app',
router,
});
Routes.js代码
import ExampleComponent from "./components/ExampleComponent.Vue";
import VueRouter from "vue-router";
const routes = [
{
path : "/",
component:ExampleComponent,
name:"home",
}
];
const router = new VueRouter({
routes // short for `routes: routes`
});
export default router;
我只是通过编辑解决了webpack.mix.js
来自
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
到
mix.js('resources/js/app.js', 'public/js').vue()
.sass('resources/sass/app.scss', 'public/css');
然后做
npm update
npm run dev
Geek's 需要很少的帮助,我们将不胜感激任何建议或提示。 问题是我正在尝试在 Laravel 上安装 Vue。但是在安装 Vue 路由器之后,我决定使用“npm 运行 watch”编译所有内容,但我在控制台上收到以下错误: 注意* 在 运行 执行“npm 运行 watch”命令之前,Vue 已被浏览器(“Vue Dev Tool”)检测到,但现在无法检测到,我不知道我在哪里做了错误:(.
ERROR in ./resources/js/components/ExampleComponent.Vue 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <template>
| <div class="container">
| <div class="row justify-content-center">
webpack compiled with 1 error
APP.js代码
require('./bootstrap');
import router from "./routes";
import VueRouter from "vue-router";
import Vue from "vue";
window.Vue = require('vue').default;
Vue.component(
'example-component',
require('./components/ExampleComponent.vue').default);
Vue.use(VueRouter);
const app = new Vue({
el: '#app',
router,
});
Routes.js代码
import ExampleComponent from "./components/ExampleComponent.Vue";
import VueRouter from "vue-router";
const routes = [
{
path : "/",
component:ExampleComponent,
name:"home",
}
];
const router = new VueRouter({
routes // short for `routes: routes`
});
export default router;
我只是通过编辑解决了webpack.mix.js
来自
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
到
mix.js('resources/js/app.js', 'public/js').vue()
.sass('resources/sass/app.scss', 'public/css');
然后做
npm update
npm run dev