link on JianShu







  • 注册Auth0站点并创建一个应用。将回调和退出登录的URL都配置为默认的http://localhost:3000
  • 全局安装vue-cli, npm -g install @vue/cli
  • 使用cli创建基础站点vue create my-project
  • 安装路由插件vue add router 采用 history模式。
# Install the CLI
npm install -g @vue/cli

# Create the application using the Vue CLI.
# When asked to pick a preset, accept the defaults
vue create my-app

# Move into the project directory
cd my-app

# Add the router, as we will be using it later
# Select 'yes' when asked if you want to use history mode
vue add router


问题 1


ERROR  Failed to compile with 1 errors                                                                                                

This dependency was not found:

* core-js/modules/ in ./src/router/index.js

To install it, you can run: npm install --save core-js/modules/

默认的 babel.config.js内容需要做对应的修改

module.exports = {
  presets: [

# 修改为
module.exports = {
  presets: [
    ['@vue/app', {
      polyfills: [
      useBuiltIns: "entry"

问题 2

    1. 提示找不到 Navigating to current location (xxx) is not allowed

这个就完全是自己引入路径不正确导致的(诡异了,昨天看的文章操作方式是新建route文件夹,里面房index.js的方式,今天复盘大家都是直接添加 router.js的方式)

采用文件夹的方式时 router下的index.js引用profile时为 import Profile from '../views/Profile.vue'方式;直接在router.js里引用则可以import Profile from "./views/Profile.vue";



使用Vue cli创建项目

vue create my-project

Vue CLI v4.1.2
? Please pick a preset: Manually select features
? Check the features needed for your project: (Press <space> to select, <a> to toggle all, <i> to invert selection)Babel, Linter
? Pick a linter / formatter config: Basic
? Pick additional lint features: (Press <space> to select, <a> to toggle all, <i> to invert selection)Lint on save
? Where do you prefer placing config for Babel, ESLint, etc.? In dedicated config files
? Save this as a preset for future projects? No
? Pick the package manager to use when installing dependencies: Yarn


📄  Generating

🎉  Successfully created project my-project.
👉  Get started with the following commands:

 $ cd my-project
 $ yarn serve


➜  my-project git:(master) vue add router

📦  Installing @vue/cli-plugin-router...

yarn add v1.17.3
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...

success Saved 1 new dependency.
info Direct dependencies
└─ @vue/cli-plugin-router@4.1.2
info All dependencies
└─ @vue/cli-plugin-router@4.1.2
✨  Done in 3.27s.
✔  Successfully installed plugin: @vue/cli-plugin-router

? Use history mode for router? (Requires proper server setup for index fallback in production) No

comments powered by Disqus