使用vue initi创建的应用程序会抛出错误 [英] App created with vue initi throws error
问题描述
我刚刚开始使用vue js而且我正在学习教程。要开始,我在命令行输入以下内容:
I just started using vue js and I was following a tutorial. To get started I type in the command line the following:
vue init webpack test-app
我插入项目标题,作者,我没有安装lint和测试框架。
我进入项目文件夹并运行npm install和npm run dev但我收到此错误:
I insert the project title, author, I don't install the lint and the test framework. I enter the project folder and run npm install and npm run dev but I get this error:
ERROR Failed to compile with 2 errors 4:58:04 PM
error in ./src/App.vue
Syntax Error: Unexpected token {
@ ./~/vue-style-loader!./~/css-loader?{"minimize":false,"sourceMap":false}!./~/vue-loader/lib/style-compiler?{"id":"data-v-17d125bb","scoped":false,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-303 13:3-17:5 14:22-311
@ ./src/App.vue
@ ./src/main.js
@ multi ./build/dev-client ./src/main.js
error in ./src/components/Hello.vue
Syntax Error: Unexpected token {
@ ./~/vue-style-loader!./~/css-loader?{"minimize":false,"sourceMap":false}!./~/vue-loader/lib/style-compiler?{"id":"data-v-369af42f","scoped":true,"hasInlineConfig":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/components/Hello.vue 4:14-313 13:3-17:5 14:22-321
@ ./src/components/Hello.vue
@ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue
@ ./src/App.vue
@ ./src/main.js
@ multi ./build/dev-client ./src/main.js
> Listening at http://localhost:8080
如果我去localhost:8080我只能看到:
And if I go to localhost:8080 I can only see:
Cannot GET /
新安装的代码有什么问题?
What can be wrong in the code with a fresh intallation?
编辑:这是App.vue文件
this is App.vue file
<template>
<div id="app">
<img src="./assets/logo.png">
<hello></hello>
</div>
</template>
<script>
import Hello from './components/Hello'
export default {
name: 'app',
components: {
Hello
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
推荐答案
我刚才遇到了同样的问题!我通过将Node.js更新到最新版本(7.7.4)来解决它。
I just had the exact same problem! I solved it by updating Node.js to the latest version (7.7.4).
这篇关于使用vue initi创建的应用程序会抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!