Home>Article>WeChat Applet> WeChat applet implements dynamic setting of page title method sharing

WeChat applet implements dynamic setting of page title method sharing

小云云
小云云 Original
2018-05-10 17:27:41 8433browse

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

   

② JS file

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

③ WXSS file

button{ margin-top:10px; }

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!

Statement:
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