// 定义变量,保存当前导航栏应该显示的内容let pageTitle = "帖子"//这里的type是通过跳转页面是将信息放到url中带过来的,然后保存到本地switch(this.type) {case "post" :pageTitle = "帖子"breakcase "topic" :pageTitle = "话题"breakcase "user" :pageTitle = "用户"break}// 如果时app端就执行下面的代码// #ifdef APP-PLUS// 修改搜索框的标题(占位 )// 获取当前的窗口实例let currentWebview = this.$mp.page.$getAppWebview();// 获取当前窗口的源生导航栏let tn = currentWebview.getStyle().titleNView;// 修改导航栏中input框中的placeholder属性值tn.searchInput.placeholder = "搜索" + pageTitle;// 通过setStyle修改源生导航栏信息currentWebview.setStyle({titleNView:tn})// #endif
uni.setNavigationBarTitl
修改标题内容
//修改当前页面内容uni.setNavigationBarTitle({title:data.title})
