lodash中get方法

_.get(object, path, [defaultValue])

参数

  1. object (Object) 要检索的对象
  2. path (Array|string) 要获取的对象路径
  3. [defaultValue] (*) 如果解析值是 undefined,这值会被返回
    实例:
var object = { 'a': [{ 'b': { 'c': 3 } }] };

_.get(object, 'a[0].b.c');
// => 3

_.get(object, ['a', '0', 'b', 'c']);
// => 3

_.get(object, 'a.b.c', 'default');
// => 'default'

项目应用 >> 获取路由信息 获取不到的话返回404

matchRouter = this.$get(this.$route, 'matched[0].path', '/404')

你可能感兴趣的:(前端)