WeChat small program dynamically adds button components

The WeChat small program dynamic loading is a button as an example. The main page clicks different buttons into different subgaps, and dynamically loads the number and values ​​of the sub-page button depending on the Title of the main page.

WXML file (note wx: key = “item” to write, otherwise it will have a warning): 微信小程序动态增加按钮组件

{{{{{{i ie}}
     The role is wx: for, here is a loop.  WXSS file:  
/ * Pages / Plan / Plans / Plans.wxss * /. Items {background-color: rosybrown; width: 60%

JS file:

// Pages / Plan / Hot / Hot.js Page ({DATA : {}, online: function (options) {var there = this; var arr = new array (); if (options.title == “hot”) {var location = {Name: “1”}; var location2 = {Name: “2”}; var location3 = {name: “3”}; var location 4 = {name: “4”}; var location: “5”}; VARLocation6 = {Name: “6”}; arr.push (location1); arr.push (location2); arr.push (location3); arr.push (location4); arr.push (location5); arr.push (location6 Console.log (“OK”);} else {var location = {Name: “2”}; var location2 = {Name: “4”}; var location = {Name: “5”}; arr.push (Location1); Arr.push (location2); arr.push (location3);} wx.setnavigationbartertle ({Title: ‘Creating a new plan -‘ + options.title}; wx.getsysteminfo ({Success: function (RES ) {That.SetData ({// view classname_height: res.WindowHeight / Arr.length, // btn array: arr,})}}}}
The above is the full content of this article, I hope to help everyone, I hope everyone will support Tumi Clouds.
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment