V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
zzzccc0812
V2EX  ›  Vue.js

vue-cli3.0 +TypeScript 类型“VueRouter”上不存在属性“options”

  •  1
     
  •   zzzccc0812 · 2020-04-01 16:31:15 +08:00 · 2134 次点击
    这是一个创建于 1483 天前的主题,其中的信息可能已经有所发展或是发生改变。

    大家好, 我在写 VUE+TS 的时候遇到了一个问题 请求大佬

    Element implicitly has an 'any' type because expression of type '"options"' can't be used to index type 'VueRouter'.
    类型“VueRouter”上不存在属性“options”
    
    
    // 在写 router 的时候用到了 options 但是会提示错误 本人目前只找到了一种解决方法就是去 Node_modules 里面去修改 请问大佬们 有没有其他更好的解决办法
    this.$router["options"].routes
    
    2 条回复    2020-04-02 19:24:05 +08:00
    geshansuiyue
        1
    geshansuiyue  
       2020-04-02 13:53:22 +08:00
    自己写个定义文件吧。
    zzzccc0812
        2
    zzzccc0812  
    OP
       2020-04-02 19:24:05 +08:00
    @geshansuiyue 大佬您好我尝试过是写在 types/然后建一个对应的.d.ts 文件吗 我貌似好像不太行
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4964 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 09:50 · PVG 17:50 · LAX 02:50 · JFK 05:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.