File tree Expand file tree Collapse file tree 3 files changed +15
-13
lines changed
Expand file tree Collapse file tree 3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change 33 position : relative;
44 display : flex;
55 flex-direction : row;
6+ justify-content : center;
67 align-items : center;
78 height : 44px ;
89 box-sizing : border-box;
910 background : # f5f6fa ;
10- background-color : # FFFFFF ;
1111 box-shadow : 0 0 transparent;
1212 font-size : 14px ;
1313 color : # 1a1a1a ;
3333 padding-left : 14px ;
3434}
3535.nut-navbar-title {
36- min- width: 53 % ;
36+ width : 50 % ;
3737 height : 100% ;
38- margin : 0 auto;
3938 text-align : center;
4039 display : flex;
4140 flex-direction : row;
4746}
4847.nut-navbar-title-align-left {
4948 min-width : 0 ;
50- margin : 0 ;
5149 flex : 1 ;
5250 justify-content : flex-start;
5351 padding : 0 8px ;
6361 display : flex;
6462 align-items : center;
6563 flex-direction : row;
64+ height : 100% ;
6665 cursor : pointer;
6766 padding : 0 14px ;
6867 /* #ifndef rn harmony jd h5 weapp*/
Original file line number Diff line number Diff line change 33 position : relative ;
44 display : flex ;
55 flex-direction : row ;
6+ justify-content : center ;
67 align-items : center ;
78 height : $navbar-height ;
89 box-sizing : border-box ;
910 background : $navbar-background ;
10- background-color : #ffffff ;
1111 box-shadow : $navbar-box-shadow ;
1212 font-size : $navbar-font-size ;
1313 color : $navbar-color ;
3737 }
3838
3939 & -title {
40- min- width : 53 % ;
40+ width : 50 % ;
4141 height : 100% ;
42- margin : 0 auto ;
4342 text-align : center ;
4443 display : flex ;
4544 flex-direction : row ;
5049 color : $navbar-title-font-color ;
5150 & -align-left {
5251 min-width : 0 ;
53- margin : 0 ;
5452 flex : 1 ;
5553 justify-content : flex-start ;
5654 padding : 0 8px ;
7068 display : flex ;
7169 align-items : center ;
7270 flex-direction : row ;
71+ height : 100% ;
7372 cursor : pointer ;
7473 padding : 0 14px ;
7574 /* #ifndef rn harmony jd h5 weapp*/
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import { ITouchEvent, View } from '@tarojs/components'
44import { useRtl } from '@/packages/configprovider/index.taro'
55import { BasicComponent , ComponentDefaults } from '@/utils/typings'
66import { getRectByTaro } from '@/utils/get-rect-by-taro'
7+ import { harmonyAndRn } from '@/utils/platform-taro'
8+ import pxTransform from '@/utils/px-transform'
79
810export interface NavBarProps extends BasicComponent {
911 left : React . ReactNode
@@ -100,7 +102,9 @@ export const NavBar: FunctionComponent<Partial<NavBarProps>> = (props) => {
100102 }
101103 setContentWidth ( centerWidth . toFixed ( 2 ) )
102104 }
103- init ( )
105+ setTimeout ( ( ) => {
106+ init ( )
107+ } , 0 )
104108 } , [ left , right , back ] )
105109
106110 const renderLeft = ( ) => {
@@ -134,11 +138,11 @@ export const NavBar: FunctionComponent<Partial<NavBarProps>> = (props) => {
134138 const renderContent = ( ) => {
135139 let titleStyle = { }
136140 if ( titleAlign === 'center' ) {
137- const contentRealWidth = `${ contentWidth } ${
138- / % $ / i. test ( contentWidth ) ? '' : 'px'
139- } `
141+ const width = harmonyAndRn ( )
142+ ? pxTransform ( Number ( contentWidth ) )
143+ : `${ contentWidth } px`
144+ const contentRealWidth = / % $ / i. test ( contentWidth ) ? contentWidth : width
140145 titleStyle = {
141- minWidth : contentRealWidth ,
142146 width : contentRealWidth ,
143147 }
144148 }
You can’t perform that action at this time.
0 commit comments