【发布时间】:2018-11-28 13:20:33
【问题描述】:
我正在尝试使用 Auth0 设置我的第一个 vue.js 2 应用程序。 API 部分工作正常,但我在 webpack 中遇到与 auth0 快速入门中描述的身份验证服务相关的错误:https://auth0.com/docs/quickstart/spa/vuejs
Module parse failed: Unexpected token (18:8)
You may need an appropriate loader to handle this file type.
| }
|
| auth0 = new auth0.WebAuth({
我不太了解这个类中使用的语法,因为 auth0 是 import 语句中使用的名称。我的应用程序是一个标准的 vue.js 脚手架生成的应用程序,带有 webpack。
这是快速入门中的整个 .js:
import auth0 from 'auth0-js'
import { AUTH_CONFIG } from './auth0-variables'
import EventEmitter from 'eventemitter3'
import router from './../router'
export default class AuthService {
constructor () {
this.login = this.login.bind(this)
this.setSession = this.setSession.bind(this)
this.logout = this.logout.bind(this)
this.isAuthenticated = this.isAuthenticated.bind(this)
}
auth0 = new auth0.WebAuth({
domain: 'omitted',
clientID: 'omitted',
redirectUri: 'http://localhost:3000/callback',
audience: 'omitted',
responseType: 'token id_token',
scope: 'openid'
})
login () {
this.auth0.authorize()
}
}
【问题讨论】: