【发布时间】:2019-02-18 17:13:50
【问题描述】:
我正在按照教程 (https://savvyapps.com/blog/definitive-guide-building-web-app-vuejs-firebase) 构建一个 vue.js 应用程序,并且在指南的某个部分中,它指示我在 Login.vue 文件的块中添加一个 login() 函数。
login() {
fb.auth.signInWithEmailAndPassword(this.loginForm.email, this.loginForm.password).then(user => {
this.$store.commit('setCurrentUser', user)
this.$store.dispatch('fetchUserProfile')
this.$router.push('/dashboard')
}).catch(err => {
console.log(err)
})
}
但是,当它被编译时,我得到一个错误:
./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/Login.vue
Module build failed: SyntaxError: C:/Users/Rohit/Documents/Javascript/vue_practice/humanity/src/components/Login.vue: Unexpected token, expected ; (33:8)
31 | const fb = require('../firebaseConfig.js')
32 |
> 33 | login() {
| ^
34 | fb.auth.signInWithEmailAndPassword(this.loginForm.email, this.loginForm.password).then(user => {
35 | this.$store.commit('setCurrentUser', user)
36 | this.$store.dispatch('fetchUserProfile')
@ ./src/components/Login.vue 4:0-105 5:0-118
@ ./src/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
我一直在尽力弄清楚语法错误是什么,但无济于事。提前感谢您的帮助!
【问题讨论】:
标签: javascript vue.js webpack vuejs2 vue-component