zzzccc0812
V2EX  ›  Vue.js

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

  •  1
     
  •   zzzccc0812 · Apr 1, 2020 · 3199 views
    This topic created in 2234 days ago, the information mentioned may be changed or developed.

    大家好, 我在写 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 replies    2020-04-02 19:24:05 +08:00
    geshansuiyue
        1
    geshansuiyue  
       Apr 2, 2020
    自己写个定义文件吧。
    zzzccc0812
        2
    zzzccc0812  
    OP
       Apr 2, 2020
    @geshansuiyue 大佬您好我尝试过是写在 types/然后建一个对应的.d.ts 文件吗 我貌似好像不太行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5462 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 08:48 · PVG 16:48 · LAX 01:48 · JFK 04:48
    ♥ Do have faith in what you're doing.