route:
(1) vue3写法:
import { useRoute } from "vue-router";
let route = useRoute();
route.query;
route.params;
(2) vue2写法:
import { getCurrentInstance } from "vue";
let { proxy: this_ }: any = getCurrentInstance();
this_.$route.query;
this_.$route.params;
router:
(1) vue3写法:
import { useRouter } from "vue-router";
let router = useRouter();
router.push("/home");
router.replace("/home");
router.go(1);
(2) vue2写法:
import { getCurrentInstance } from "vue";
let { proxy: this_ }: any = getCurrentInstance();
this_.$router.push("/home");
this_.$router.replace("/home");
this_.$router.go(1);
store:
(1) vue3写法:
import { useStore} from "vuex";
let store= useStore();
store.state.list;
store.commit("getList",res.data);
store.dispatch("getList",res.data);
store.getters.getList;
(2) vue2写法:
import { getCurrentInstance } from "vue";
let { proxy: this_ }: any = getCurrentInstance();
this_.$store.state.list;
this_.$store.commit("getList",res.data);
this_.$store.dispatch("getList",res.data);
this_.$store.getters.getList;