[英]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.您要导出的对象在
data
或methods
键后没有逗号,即使其他键紧随其后。
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.