动态设置小程序顶部或者头部的标题栏内容

三步:

1. name属性非常重要

<input class="weui-input" type="text" placeholder="请输入页面标题并点击设置即可" name="title"></input>

2.  formType="submit" 属性非常重要

<button type="primary" formType="submit">设置</button>

3 setNaivgationBarTitle 方法很重要

  setNaivgationBarTitle: function (e) {
    console.log(e.detail.value) //获取当前表单提交的内容title
    var title = e.detail.value.title
    console.log(title)
    wx.setNavigationBarTitle({
      title: title,
      success: function() {
        console.log('setNavigationBarTitle success')
      },
      fail: function(err) {
        console.log('setNavigationBarTitle fail, err is', err)
      }
    })

    return false
  }

 

 

 

 

 

 
posted @ 2018-11-15 15:07  10后程序员劝退师  阅读(4403)  评论(0)    收藏  举报