Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何正确扩展Vue NavigationGuardNext typescript接口以添加元属性_Javascript_Typescript_Vue.js_Types_Vuejs2 - Fatal编程技术网

Javascript 如何正确扩展Vue NavigationGuardNext typescript接口以添加元属性

Javascript 如何正确扩展Vue NavigationGuardNext typescript接口以添加元属性,javascript,typescript,vue.js,types,vuejs2,Javascript,Typescript,Vue.js,Types,Vuejs2,我在尝试扩展Vue库为NavigationGuardNext公开的接口时遇到了问题。我想扩展这个回调,以接受带有子对象的元字段 路由器公开以下内容: router.beforeach((to,from,next)其中next的类型为NavigtionGuardNext 然后,我想以这种方式使用下一次回调,如下所示: next({ name: 'login', path: '/login', meta: { pri

我在尝试扩展Vue库为
NavigationGuardNext
公开的接口时遇到了问题。我想扩展这个回调,以接受带有子对象的元字段

路由器公开以下内容:

router.beforeach((to,from,next)
其中next的类型为
NavigtionGuardNext

然后,我想以这种方式使用下一次回调,如下所示:

next({
          name: 'login',
          path: '/login',
          meta: {
            private: false
          },
          params: { nextUrl: to.fullPath }
        })
这里的问题是,
meta
在typescript中无效。我尝试使用以下方法扩展它,但似乎无法使其正常工作:

interface ExtendedNavigationGuard extends NavigationGuardNext<Vue> {
  meta: { private: boolean }
}
接口ExtendedNavigationGuard扩展NavigationGuardNext{
元:{private:boolean}
}
我还发现了以下合并,其中更新了定义以允许扩展:

有人能告诉我如何将meta字段添加到这个保护中,以允许在中间件中传递这个字段,而无需键入errros吗