8.12

48 阅读1分钟

sessionStorage

  • 仅在当前会话下有效。
  • 即使是刷新或者进入同源(指协议、域名、端口号相同)的另一个页面,数据仍在。
  • 关闭窗口后sessionStorage会被销毁。
  • 可以进行setItem、getItem、removeItem等操作。
//存储
sessionStorage.setItem(
    "columnList",
    JSON.stringify([...Array, ...res.data.list])
);
//获取
sessionStorage.getItem('loadClaim');
//删除
sessionStorage.removeItem('type');

watch监听路由改变

  • 适用于:点击导航栏进行跳转时,面包屑、路由发生变化,但页面未改变。
$route(to, from) {
    if (to.path == "/article/articleList") {
        console.log("检测到页面跳转到相同地方");
        //
        const form = JSON.parse(this.$route.query.cl);
        this.form.columnId = form.columnId;
        this.form.columnType = form.columnType;
        if (form.columnType == 7) {
            this.form.queryAllSecond = 1;
        }
        this.form.limit = this.$route.query.numLine?this.$route.query.numLine:8;
        this.initData();
        console.log("看看初始化数据成功没");
    }
}