使用vue initi创建的应用程序会抛出错误

时间:2017-03-22 17:05:53

标签: javascript vue.js vuejs2

我刚刚开始使用vue js而且我正在学习教程。要开始,我在命令行输入以下内容:

vue init webpack test-app

我插入了项目标题,作者,我没有安装lint和测试框架。 我进入项目文件夹并运行npm install和npm run dev但我收到此错误:

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,我只能看到:

Cannot GET /

新安装的代码有什么问题?

编辑:这是App.vue文件

<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>

1 个答案:

答案 0 :(得分:3)

我刚才遇到了同样的问题!我通过将Node.js更新到最新版本(7.7.4)来解决它。