-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
Tabs
tab-cell support "updateLayout" method (#234)
- Loading branch information
1 parent
1cf9c0e
commit 1f17383
Showing
5 changed files
with
234 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
## font-size 改变需要重新 rerender tab-cell @en{Font-size changes require rerendering tab-cell} | ||
|
||
#### 12 | ||
|
||
```js | ||
import { Tabs, Button } from '@arco-design/mobile-react'; | ||
|
||
const tabData = [ | ||
{ title: 'Example1' }, | ||
{ title: 'Example2' }, | ||
{ title: 'Example3' }, | ||
{ title: 'Example4' }, | ||
{ title: 'Example5' }, | ||
{ title: 'Example6' }, | ||
{ title: 'Example7' }, | ||
]; | ||
|
||
export default function TabsDemo() { | ||
const theRef = React.useRef(); | ||
const handleClick = () => { | ||
if (theRef.current) { | ||
var divNodes = theRef.current.bar.dom.getElementsByTagName("div"); | ||
for (var i = 0; i < divNodes.length; i++) { | ||
divNodes[i].setAttribute("style", "font-size: 32px!important;"); | ||
} | ||
setTimeout(() => { | ||
theRef.current.bar.updateLayout(); | ||
}, 20) | ||
} | ||
} | ||
return ( | ||
<> | ||
<Button onClick={handleClick}>点击放大字体</Button> | ||
<Tabs | ||
ref={theRef} | ||
tabs={tabData} | ||
tabBarPadding={{ left: 22, right: 64 }} | ||
tabBarGutter={42} | ||
defaultActiveTab={3} | ||
onAfterChange={(tab, index) => { | ||
console.log('[tabs]', tab, index); | ||
}} | ||
translateZ={false} | ||
tabBarHasDivider={false} | ||
> | ||
<div className="demo-tab-content">Content area</div> | ||
<div className="demo-tab-content">Content area</div> | ||
<div className="demo-tab-content">Content area</div> | ||
<div className="demo-tab-content">Content area</div> | ||
<div className="demo-tab-content">Content area</div> | ||
<div className="demo-tab-content">Content area</div> | ||
<div className="demo-tab-content">Content area</div> | ||
</Tabs> | ||
</> | ||
); | ||
} | ||
``` | ||
|
||
```less | ||
.demo-tab-content { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
.rem(font-size, 15); | ||
.rem(height, 80); | ||
.use-var(color, sub-info-font-color); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters