[英]Materialize css all tabs coming together below each other, but working properly after refresh
I use materialize css tabs and it loads all the divs, one below the other on the first load. 我使用物化css标签,它会加载所有div,在第一次加载时一个在另一个下面。
If i refresh the page, it starts behaving properly. 如果我刷新页面,它将开始正常运行。
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s3"><a href="#test1">Test 1</a></li>
<li class="tab col s3"><a class="active" href="#test2">Test 2</a></li>
<li class="tab col s3 disabled"><a href="#test3">Disabled Tab</a></li>
<li class="tab col s3"><a href="#test4">Test 4</a></li>
</ul>
</div>
<div id="test1" class="col s12">Test 1</div>
<div id="test2" class="col s12">Test 2</div>
<div id="test3" class="col s12">Test 3</div>
<div id="test4" class="col s12">Test 4</div>
This just gives me the snippet below on the first load / server restart: 这只是给我以下第一次加载/服务器重启时的代码段:
Now, if i refresh the page. 现在,如果我刷新页面。 It works as expected. 它按预期工作。
I imported all the required js(jquery and materialize) and css and I also added the initialization for tabs. 我导入了所有必需的js(jquery和materialize)和css,并且还添加了选项卡的初始化。
$(window).on("load", function () {
$('ul.tabs').tabs();
});
i have tried 我努力了
$(document).ready(function () {
$('ul.tabs').tabs();
});
The issue still persists. 问题仍然存在。
Anyone know the solution to this? 有人知道解决方案吗?
I am facing too many issues like these with materialize. 我面临着太多像这样的问题。
Also, I use react. 另外,我使用react。 If that makes any difference. 如果有什么不同。
Using react-materialize, I face the below issue. 使用react-materialize,我面临以下问题。
<Tabs className='tab purple darken-4'>
<div className="container">
<Tab title="All">1</Tab>
<Tab title="Ongoing" active>2</Tab>
<Tab title="Successful">3</Tab>
<Tab title="Failed/Warning">4</Tab>
</div>
</Tabs>
When you use Tabs component; 当您使用Tabs组件时; react-materialize get the child components and renders them accordingly. react-materialize获取子组件并相应地渲染它们。 Since you are wrapping all components with a single div the render breaks. 由于用单个div包装所有组件,因此渲染中断。
You can try doing something like this; 您可以尝试执行以下操作;
<div className="container">
<Tabs className='tab purple darken-4'>
<Tab title="All">1</Tab>
<Tab title="Ongoing" active>2</Tab>
<Tab title="Successful">3</Tab>
<Tab title="Failed/Warning">4</Tab>
</Tabs>
</div>
OR 要么
<Tabs className='tab purple darken-4'>
<Tab title="All">
<div className="container">
1
</div>
</Tab>
<Tab title="Ongoing">
<div className="container">
2
</div>
</Tab>
<Tab title="Successful">
<div className="container">
3
</div>
</Tab>
<Tab title="Failed/Warning">
<div className="container">
4
</div>
</Tab>
</Tabs>
If you like to change the apperiance of the Tabs or a single Tab component you can use className
prop for them too. 如果您想更改Tab或单个Tab组件的外观,则也可以为其使用className
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.