2017-05-25 66 views
0

我创建了我auth0配置,我现在导入我的登录页面当我尝试将vue组件连接到我的router.js文件时,会出现什么错误?

import Vue from 'vue' 
import Router from 'vue-router' 


Vue.use(Router) 


// create import statements 
import login from './containers/login' 
import home from './containers/home' 
import dashboard from './containers/dashboard' 
import projects from './containers/projects' 
import auth from './auth' 


// application routes 

const routes = [ 

// each path will render each component when it experiences an event 

{ path: '/', component: home }, 
{ path: '/dashboard', component: dashboard }, 
{ path: '/projects', component: projects } 

] 


// export router instance 

/* Using mode : 'history ' 
This removes the hash from the url and gives 
the app a cleaner url string 
*/ 


export default new Router({ 
    mode: 'history', 
    routes, 

/* use link activeClass to indicate what 
class to add to the navigation to make the menu item active 

*/ 


    linkActiveClass: 'is-active' 
}) 

我遇到了这个错误,虽然

Syntax Error: import is a reserved word (32:2) 

的login.vue和auth.js之前加入代码是功能性的,但是当我输入它时会返回上述错误。

我使用vue.js框架和Auth0来确保安全。

+0

为什么你想在你不需要时导入auth.js? –

回答

0

导入是ES2016中的一个关键字,它是一个新的JavaScript标准。对我来说,它看起来像你正在使用ES5,这是目前在大多数浏览器中可用的版本。要使用ES6功能,您需要使用Babel等工具将代码转换为ES5。如果您根据教程使用vue-cli创建项目,则Babel应自动配置到您的项目中。

相关问题