使用location.href=’/url’来跳转,简单方便,但是刷新了页面;
使用history.pushState(’/url’),无刷新页面,静态跳转;

引进router,然后使用router.push(’/url’)来跳转,使用了diff算法,实现了按需加载,减少了dom的消耗。
其实使用router跳转和使用history.pushState()没什么差别的,因为vue-router就是用了history.pushState(),尤其是在history模式下。

this.$router.push(path) 介绍:

- 跳转到指定URL,向history栈添加一个新的记录;
- 点击后退会返回至上一个页面

window.location.href和this.$router.push区别的更多相关文章

  1. window.location.href 和 window.location.replace 的区别

    window.location.href  和  window.location.replace 的区别 1.window.location.href=“url”:改变url地址: 2.window. ...

  2. window.location.href和window.location.replace的区别

    有3个html页面(.html, .html, .html). 进系统默认的是1.html ,当我进入2.html的时候, .html里面用window.location.replace(" ...

  3. window.location.href和window.open的几种用法和区别

    使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...

  4. JS中 window.location 与window.location.href的区别

    疑惑:window.location='url'  与window.lcoation.href='url'效果一样,都会跳转到新页面,区别在哪?查得的资料如下: 1:window.location是页 ...

  5. JS 中document.URL 和 window.location.href 的区别

    实际上,document 和 window 这两个对象的区别已经包含了这个问题的答案. document 表示的是一个文档对象,window 表示一个窗口对象. 一个窗口下面可以有很多的documen ...

  6. window.location.Reload()和window.location.href 区别

    首先介绍两个方法的语法: reload 方法,该方法强迫浏览器刷新当前页面.语法:location.reload([bForceGet])参数: bForceGet, 可选参数, 默认为 false, ...

  7. window.location.replace和window.location.href的区别

    简单说说:有3个jsp页面(1.jsp,  2.jsp,  3.jsp). 进系统默认的是1.jsp ,当我进入2.jsp的时候, 2.jsp里面用window.location.replace(&q ...

  8. window.location.replace()与window.location.href()区别

    有3个页面 a,b,c 如果当前页面是c页面,并且c页面是这样跳转过来的:a->b->c 1:b->c 是通过window.location.replace("..xx/c ...

  9. window.location.href 与 window.loaction.replace区别

    window.location.href和window.location.replace的区别 1.window.location.href=“url”:改变url地址: 2.window.locat ...

  10. window.location.assign和window.location.href区别

    window.location.assign和window.location.href区别 window.location.assign(url)和window.location.href=url实现 ...

随机推荐

  1. SpringBoot相关注解使用

    @MapperScan注解和@Mapper @Mapper常用在相应的 *Mapper类上,但是每个类都使用相对麻烦,所以后来用@MapperScan替代 ,@MapperScan注解使用在启动类上. ...

  2. QT - Day 2

    QMainWindow 菜单栏  最多有一个 QMenuBar *bar = MenuBar(); setMenuBar(bar); QMenu *fileMenu = bar->addMenu ...

  3. Celery异步处理任务时遇到的错误ValueError: not enough values to unpack (expected 3, got 0)

    开启celery异步,终端命令: celery -A celery_tasks.main worker -l info 如果上面运行后,发送短信码的时候没有报如下错误: ValueError: not ...

  4. docker开发

    Docker docker介绍 Docker是一个客户端-服务器(C/S)架构程序.本质上是通过go语言对lxc技术的一个封装,遵守Restful规范 docker hub注册一个账号(用来拉取镜像) ...

  5. 【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.

    问题描述 PHP的Web Job,通过artisan来配置路径启动PHP任务,相关启动脚本如下: artisan_path = "d:\\home\\site\\wwwroot"; ...

  6. 【Azure Developer】开发模式下使用AAD账号访问Azure Blob的相关参考

    问题描述 开发模式下使用AAD账号访问Azure Blob的流程参考文件 问题解答 第一步:先在AAD中注册一个APP,步骤可参考: 将应用程序注册到 Microsoft 标识平台 :https:// ...

  7. 【Azure 云服务】当Windows系统发布新的安全漏洞后,如何查看Azure云服务(Cloud Service)的实例是否也更新了安全补丁呢?

    问题描述 当Windows发布新的安全漏洞后,会根据安全漏洞的级别分类来确定是紧急打补丁升级,还是每一月的补丁日( 每月第二周的星期二)来统一推送补丁. 比如最近的一个安全漏洞(9月13号发布)  C ...

  8. ArrayList学习总结

    1.ArrayList简介[1] ArrayList实现了List接口.ArrayList的方法实现和vector相似,只是线程不安全的. ArrayList的 size.isEmpty.get.se ...

  9. Docker下搭建MySql主从复制

    在Docker环境下搭建MySql主从复制,阅读此文章默认读者具备基础的Docker命令操作. 一.环境 1.Docker版本:Docker version 24.0.5, build ced0996 ...

  10. window.open代理劫持

    window.open = new Proxy(window.open, { apply(target, ctx, args) { if (hasAuth(args[0])) { return tar ...