微信小程序 navigationBarTitleText 不显示

微信小程序 navigationBarTitleText 不显示,原因是默认创建的配置是是定义的:

如图所示:

把图中的2处修改如下,后 navigationBarTitleText 显示正常

如果你在微信小程序中使用navigationBarTitleText设置导航栏标题,但是标题不居中,可以尝试以下方法: 1. 设置页面的样式为"navigationStyle":"custom",这样可以自定义导航栏样式。 2. 在导航栏中添加一个view,并设置该view的flex布局,使标题居中显示。 示例代码如下: ``` { "navigationBarTitleText": "标题", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", "usingComponents": {}, "backgroundTextStyle": "dark", "backgroundColor": "#f8f8f8", "enablePullDownRefresh": false, "onReachBottomDistance": 50, "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationBarTitleText": "标题", "backgroundTextStyle": "dark" } ``` 在页面的wxml文件中添加以下代码: ``` <view class="nav-title">{{navigationBarTitleText}}</view> ``` 在页面的wxss文件中添加以下代码: ``` .nav-title { display: flex; justify-content: center; align-items: center; height: 100%; font-size: 16px; font-weight: bold; } ``` 通过以上方法,可以让标题居中显示
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值