简体   繁体   English

当我输入“npm run serve”时,我得到一个 SyntaxError。 错误是:意外的令牌,预期的“,”(45:2)。 我究竟做错了什么?

[英]I get a SyntaxError when I type 'npm run serve'. The error is: Unexpected token, expected "," (45:2). What am I doing wrong?

I get a SyntaxError when I type: npm run serve键入时出现语法错误: npm run serve

The error is: Unexpected token, expected "," (45:2)错误是: Unexpected token, expected "," (45:2)

What am I doing wrong?我究竟做错了什么?

I am working with Pusher and Vue.js in Visual-Studio-Code.我正在 Visual-Studio-Code 中使用 Pusher 和 Vue.js。

This is a Tutorial from a Website : https://www.sitepoint.com/pusher-vue-real-time-chat-app/这是来自网站的教程: https : //www.sitepoint.com/pusher-vue-real-time-chat-app/

Below is my Code.下面是我的代码。 Please help me guys!!请大家帮帮我!!

    <template>
  <div class="login-form">
    <h5 class="text-center">Chat Login</h5>
    <hr>
    <b-form @submit.prevent="onSubmit">
       <b-alert variant="danger" :show="hasError">{{ error }} </b-alert>

      <b-form-group id="userInputGroup"
                    label="User Name"
                    label-for="userInput">
        <b-form-input id="userInput"
                      type="text"
                      placeholder="Enter user name"
                      v-model="userId"
                      autocomplete="off"
                      :disabled="loading"
                      required>
        </b-form-input>
      </b-form-group>

      <b-button type="submit"
                variant="primary"
                class="ld-ext-right"
                v-bind:class="{ running: loading }"
                :disabled="isValid">
                Login <div class="ld ld-ring ld-spin"></div>
      </b-button>
    </b-form>
  </div>
</template>

// something after .env


<script>
import { mapState, mapGetters, mapActions } from 'vuex'

export default {
  name: 'login-form',
  data() {
    return {
      userId: '',
    }
  }
  methods: {
    ...mapActions ([
      'login'
    ]),
    async onSubmit() {
      const result = await this.login(this.userId);
      if(result) {
        this.$router.push('chat');
      }
    }
  }
  computed : {
    isValid: function(){
      const result = this.userId.length < 3;
      return result ? result : this.loading
    },
    ...mapState([
      'loading'
      'error'      
    ]),
    ...mapGetters([
      'hasError'
    ])
  }
}

</script>

You're missing some commas in your object.您的对象中缺少一些逗号。 Javascript objects need commas between keys. Javascript 对象需要在键之间使用逗号。

let object = {
  key: "value",
  otherKey: "otherValue"
}

Note the , after "value" .注意,"value"

The object you're exporting doesn't have a comma after the data or methods keys, even though other keys follow.您要导出的对象在datamethods键后没有逗号,即使其他键紧随其后。

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我在尝试“npm run serve”时会出错? - why do i get a error when trying to "npm run serve"? 当我运行 node js 时,我收到一个错误: SyntaxError: Unexpected token &#39;&lt;&#39; - When I run node js I receive an error: SyntaxError: Unexpected token '<' npm创建了大量文件,我在做什么错? - npm creates huge number of files, what am I doing wrong? 我的 npm 不断崩溃。 我究竟做错了什么? - my npm keeps crashing. what am i doing wrong? 文件类型的npm模块尽管被缓冲区调用仍返回null,我在做什么错呢? - file-type npm module returns null despite being called with buffer, what am I doing wrong? 在我的angular2应用程序上运行npm install和ng serve时,出现以下错误 - I am getting an below error when i run npm install and ng serve on my angular2 application 使用 UUID npm 模块出现奇怪错误。 我究竟做错了什么? - Getting strange error using UUID npm module. What am I doing wrong? 我试图用流星运行我在做错什么? - What am I doing wrong trying to make this run with meteor? NPM模块触发“ SyntaxError:意外令牌…”! 我如何解决它? - NPM Module triggering a “SyntaxError: Unexpected token …”! How do I fix it? 在使用承诺时我仍然得到厄运的金字塔,我做错了什么? - I still get the pyramid of doom when using promises, what am I doing wrong?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM