vue-router3 源码注释系列 /src/util/location.js

/* @flow */

import type VueRouter from '../index'
// parsePath:用于拆分成 { path: string, query: object, hash: string } 的形式。
// resolvePath: 用于将相对路径根据 current route 拼接路径成绝对形式的路径。
import {
    parsePath, resolvePath } from './path'
//resolveQuery() 将所有的 query 统一到一个对象中。
import {
    resolveQuery } from './query'
//fillParams 将 routes 中配置的动态参数,用 params 传参进行填充。
import {
    fillParams } from './params'
//警告
import {
    warn } from './warn'
//用于数据的浅拷贝
import {
    extend } from './misc'

/*  
    normalizeLocation()   归一化路径
    第一个参数: to, 可以是对象,也可以是对象。
    第二个参数: current,就是 this.$route 对象。
        {
          fullPath: "/" //完整路径。
          hash: ""      //hash部分的字符串。
          matched: []   //record 数组。
          meta: {}      //record 中记录的 meta。 
          name: null    //路由名字
          params: {}    //路径动态参数  比如:  /:userId
          path: "/"     //短路径  
          query: {}     //?后面的参数
        }
    第三个参数:append, 表示相对路径是否追加基准路径。
    第四个参数:router, 就是 this.$router 对象。    


  localtion 返回的结果为:
    return {
      _normalized: true,
      name, //name, path 同时存在的情况下,优先使用 name。
      path, //就是 window.location.href 的 pathname 部分。
      query,
      hash,
    }       
  */
export function normalizeLocation(
  raw: RawLocation,
  current: ?Route,
  append: ?boolean,
  router: ?VueRouter
): Location {
   
  //如果 raw 是字符串,则
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WARN "css.modules" option in vue.config.js is deprecated now, please use "css.requireModuleExtension" instead. INFO Starting development server... 98% after emitting CopyPlugin WARNING Compiled with 17 warnings 09:43:57 warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'computed' was not found in 'vue' warning in ./src/router/index.js "export 'default' (imported as 'VueRouter') was not found in 'vue-router' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'defineComponent' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'getCurrentInstance' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'h' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'inject' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'nextTick' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onActivated' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onDeactivated' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onUnmounted' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'provide' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'reactive' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'ref' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'shallowRef' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'unref' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'watch' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'watchEffect' was not found in 'vue'这个报错因为什么
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值