裸奔的跳蚤 發表於 2020-9-28 14:04:00

uni-app页面title问题

<p><span style="font-size: 18px">问题:一开始在uni-app里pages.json的title怎么设置都显示首页</span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:false;"> {
      "path": "pages/completionPlan/index",
      "style": {
      "navigationBarTitleText": "计划",
      "enablePullDownRefresh": true
      }
    },</pre>
</div>
<p><span style="font-size: 18px">解决方案:在页面的js里加入titleFix</span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">import titleFix from "@/utils/mixins/titleFix";

export default {
name: "page-completionPlan-index",
mixins: ,
}
</pre>
</div>
<p>  <span style="font-size: 15px">utils里的内容:</span></p>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">export default {
onShow() {
    const pages = getCurrentPages();
    const curPage = pages;
    const curSourceTitle = curPage.$holder.navigationBarTitleText;
    // 先判断是否是在钉钉中运行此应用
    if (dd.env.platform != "notInDingTalk") {
      // 钉钉必须用自己的api更新title
      dd.ready(function() {
      // dd.ready参数为回调函数,在环境准备就绪时触发,jsapi的调用需要保证在该回调函数触发后调用,否则无效。
      dd.biz.navigation.setTitle({
          title: curSourceTitle, //控制标题文本,空字符串表示显示默认文本
          onSuccess: function(result) {
            // alert(JSON.stringify(result));
          },
          onFail: function(err) {}
      });
      });
    } else {
      console.warn("请在钉钉中访问本应用!");
    }
}
};
</pre>
</div>
<p>  </p>
<p>&nbsp;</p>

</div>
<div id="MySignature" role="contentinfo">
    菜鸟自己的小记录,如有错请大佬纠错<br><br>
来源:https://www.cnblogs.com/kuoluozq/p/13744400.html
頁: [1]
查看完整版本: uni-app页面title问题