html标签“/href"的区别和导航链接或链接 [英] difference between html tag "/href" and navlink or Link

查看:42
本文介绍了html标签“/href"的区别和导航链接或链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

html标签/href"和react-router提供的导航页面的navlink有什么区别?我可以使用两者来将页面导航到不同的 URL,那么为什么需要引入 Navlink 或 Link?

what is the difference between html tag "/href" and navlink provided by react-router to navigate the page? I can use both in order to navigate page to the different URL, so why there was need of introducing Navlink or Link?

推荐答案

href 属性会触发页面刷新,从而重置应用程序状态.但是 react-router 的 link 和 navlink 不会触发页面刷新.由于 React 大部分时间用于创建单页应用程序,因此在使用路由时请确保选择 Link 或 Navlink

The href attribute would trigger a page refresh which would reset the application states. However the link and navlink of react-router doesn't trigger a page refresh. Since React is used to create single page applications most of the time make sure you choose Link or Navlink when working with routing

这篇关于html标签“/href"的区别和导航链接或链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆