微信小程序navigationBarTitleText不显示

*微信小程序navigationBarTitleText不显示

  1. 在自己pages页面配置过json文件,但是navigationBarTitleText还是不显示*
    在这里插入图片描述

  2. 找到app.json文件,然后找到pages配置代码,把新建的文件路径名写上去就可以

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果你在微信小程序中使用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、付费专栏及课程。

余额充值