uniapp修改顶部标题

uni.setNavigationBarTitle({
title:'设置标题(可以是变量)'
})
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
若需要在uniapp中自定义顶部导航栏的大小,可以通过修改页面的样式来实现。 1. 在对应页面的 `style` 中添加以下样式: ```css /* 设置导航栏高度为60px(根据实际需要修改) */ .uni-bar { height: 60px; } /* 设置左侧返回按钮的大小(可选) */ .uni-icon-back { width: 24px; height: 24px; } ``` 2. 在模板中添加自定义导航栏组件,设置导航栏高度和返回按钮大小: ```html <template> <view class="navigation"> <view class="uni-bar"> <view class="uni-icon-back"></view> <view class="title">{{title}}</view> </view> </view> </template> <script> export default { props: { title: { type: String, default: '' } } } </script> <style> .navigation { height: 60px; width: 100%; } .uni-bar { height: 60px; background: #fff; display: flex; justify-content: flex-start; align-items: center; padding-left: 20px; /* 修改左右边距根据实际需要 */ padding-right: 20px; border-bottom: 1px solid #e5e5e5; } .uni-icon-back { width: 24px; height: 24px; background: url("/static/返回按钮.png"); /* 修改返回按钮图片根据实际需要 */ background-size: contain; } .title { font-size: 18px; font-weight: bold; color: #333; margin-left: 20px; } </style> ``` 3. 在业务页面中引用自定义导航栏组件,并传入标题参数: ```html <template> <view> <custom-navigation title="自定义导航栏"></custom-navigation> <!-- 页面内容 --> </view> </template> <script> import CustomNavigation from '@/components/CustomNavigation.vue' export default { components: { CustomNavigation } } </script> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值