swan.setNavigationBarTitle

解释:动态设置当前页面的标题。

方法参数

Object object

object参数说明

示例

在开发者工具中预览效果

扫码体验

请使用百度APP扫码

代码示例

  1. <view class="container"> <view class="card-area"> <input bind:input="titleInput" class="input border-bottom" type="text" placeholder="请输入页面标题并点击设置即可"/> <button bind:tap="setNavigationBarTitle" type="primary" hover-stop-propagation="true">设置</button> </view></view>
  1. Page({ data: { newTitle: '' }, titleInput(e) { this.setData('newTitle', e.detail.value); }, setNavigationBarTitle(e) { let newTitle = this.getData('newTitle'); if (!newTitle) { swan.showToast({ title: '请输入标题' }); return; } swan.setNavigationBarTitle({ title: newTitle }); }});

错误码

Android

iOS