route:
(1) vue3写法:文章来源:https://www.toymoban.com/news/detail-541193.html
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写法:文章来源地址https://www.toymoban.com/news/detail-541193.html
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;
到了这里,关于vue3中使用route、router、store的方式的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!