“您可能需要一个合适的加载程序来处理这种文件类型"webpack 和 vue [英] "You may need an appropiate loader to handle this file type" webpack and vue

查看:23
本文介绍了“您可能需要一个合适的加载程序来处理这种文件类型"webpack 和 vue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下命令编译 webpack:

I'm trying to compile webpack with the command:

node_modules/.bin/webpack

node_modules/.bin/webpack

我得到错误:

Module parse failed: 
/home/vagrant/Code/stream/resources/assets/js/views/Contact.vue 
Unexpected token (1:0)
You may need an appropriate loader to handle this file type.

webpack 显示每个扩展名为 .vue 的文件中的错误

webpack show the error in each file with extension .vue

我的路线是这样的

import VueRouter from 'vue-router';

let routes = [
{
    path: '/',
    component: require('./views/Home')
},

{
    path: '/about',
    component: require('./views/Test')
},

{
    path: '/contact',
    component: require('./views/Contact')
}
];

export default new VueRouter({
routes,
linkActiveClass: 'is-active'
});

推荐答案

正如错误信息所暗示的:

As the error message implies:

您可能需要一个合适的加载器来处理这种文件类型.

You may need an appropriate loader to handle this file type.

您需要将 vue-loader 添加到您的 webpack 配置中.

You need to add vue-loader to your webpack configuration.

您可以在此处找到此类集成的示例:
https://github.com/vuejs-templates/webpack-simple

You can find an example of such an integration here:
https://github.com/vuejs-templates/webpack-simple

这篇关于“您可能需要一个合适的加载程序来处理这种文件类型"webpack 和 vue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆