![](/img/trans.png)
[英]How to switch between CSS styles of React components when changing routes?
[英]How to implement this kind of loader when changing routes on react
按媒体使用本教程,它显示了一个有用的示例。
将此添加到 Header 或 index.html 或 index.js(父组件)
<progress value="20" max='100'></progress>
将 jquery 添加到该 html 页面
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
然后在这个脚本标签下面添加这个
<script>
$(window).scroll(function(){
$('progress').val(($(window)[0].scrollY+$(window)[0].innerHeight)*100/$(document).height())
})
</script>
请注意,您可以通过 css 设置进度条的样式
progress{
...//css
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.