Home > WeChat Applet > Mini Program Development > WeChat applet implements dynamic setting of page title method sharing

WeChat applet implements dynamic setting of page title method sharing

小云云
Release: 2018-05-10 17:27:41
Original
8553 people have browsed it

This article mainly introduces the method of dynamically setting page titles in WeChat mini programs, involving implementation techniques related to event binding of WeChat mini program button components and dynamic setting of page element attributes. It also comes with complete source code for readers to download for reference. Friends who need it can For reference, I hope it can help everyone.

The example in this article describes the method of dynamically setting the page title in the WeChat applet. Share it with everyone for your reference, the details are as follows:

1. Effect display

2. Key code

① WXML file

<button bindtap="setBiaoTi1">标题1</button>
<button bindtap="setBiaoTi2">标题2</button>
<button bindtap="setBiaoTi3">标题3</button>
<button bindtap="back">还原</button>
Copy after login

② JS file

Page({
 // 设置标题为:标题1
 setBiaoTi1:function(){
  wx.setNavigationBarTitle({
   title: &#39;标题1&#39;,
  })
 },
 // 设置标题为:标题2
 setBiaoTi2: function () {
  wx.setNavigationBarTitle({
   title: &#39;标题2&#39;,
  })
 },
 // 设置标题为:标题3
 setBiaoTi3: function () {
  wx.setNavigationBarTitle({
   title: &#39;标题3&#39;,
  })
 },
 // 设置标题为:动态设置页面标题
 back:function(){
  wx.setNavigationBarTitle({
   title: &#39;脚本之家 - 动态设置页面标题&#39;,
  })
 }
})
Copy after login

③ WXSS file

button{
 margin-top:10px;
}
Copy after login

Related recommendations:

React operates real DOM to achieve dynamic bottom sucking

Detailed explanation of using jQuery to dynamically add small ads

Combined with css and using Html to achieve the report effect of dynamically displaying color blocks

The above is the detailed content of WeChat applet implements dynamic setting of page title method sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template