problem description
vue+typescript+vue-router: has declared global method project compilation error TS2339: Property"$router" does not exist on type "Login".
the environmental background of the problems and what methods you have tried
using this ["$router"] and defining global variables, recompiling will still report the same error
related codes
/ / Please paste the code text below (do not replace the code with pictures)
vuw-shim.d.ts file
declare module "*.vue" {
import Vue from "vue"
export default Vue;
}
//
declare module "vue/types/vue" {
import VueRouter, {Route} from "vue-router"
import VueI18n from "vue-i18n"
interface Vue {
$message: any;
// $i18n: VueI18n;
$router: VueRouter;
$route: Route;
}
}
call
this.$router.push("/userCenter")