国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 課堂 > 小程序 > 正文

微信小程序動態增加按鈕組件

2020-03-21 16:10:40
字體:
來源:轉載
供稿:網友

這里的微信小程序動態加載是以按鈕為例,主頁面點擊不同的按鈕進入不同的子頁面中,根據主頁面的title來動態加載子頁面按鈕的數量以及值。

效果圖:

按鈕,微信小程序,組件

wxml文件(注意wx:key="item"要寫,不然它會有警告):

<!--pages/plan/plans/plans.wxml--><view class="className" style="background-color: rgb(225, 218, 211); height:{{className_height}}px" wx:for="{{array}}" wx:key="item">  <button class="items" id="{{stv.id[index]}}">{{item.name}}</button></view>

這里起關鍵作用的是wx:for,這里是循環。

wxss文件:

/* pages/plan/plans/plans.wxss */.items {  background-color: rosybrown;  width:60%; }

js文件:

// pages/plan/hot/hot.js Page({  data: { },  onLoad: function (options) {  var that = this;  var arr = new Array();  if (options.title == "熱門") {   var location1 = { name: "1" };   var location2 = { name: "2" };   var location3 = { name: "3" };   var location4 = { name: "4" };   var location5 = { name: "5" };   var location6 = { 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 location1 = { name: "2" };   var location2 = { name: "4" };   var location3 = { name: "5" };    arr.push(location1);   arr.push(location2);   arr.push(location3);   }  wx.setNavigationBarTitle({title:'創建新計劃--'+options.title});  wx.getSystemInfo({   success: function (res) {    that.setData({     //view     className_height: res.windowHeight / arr.length,     //btn     array: arr,    })   }  })  },})

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沐川县| 东乡族自治县| 蓝田县| 乌兰浩特市| 大洼县| 凤阳县| 屯门区| 砀山县| 兴安县| 通化市| 昭平县| 崇信县| 伊通| 平阳县| 拜城县| 鄂托克旗| 岳普湖县| 报价| 佛学| 枣阳市| 哈密市| 基隆市| 嵊泗县| 揭西县| 吴堡县| 阿瓦提县| 吉安市| 榆树市| 浦县| 汾阳市| 来宾市| 枝江市| 墨竹工卡县| 岫岩| 万山特区| 济源市| 巴楚县| 松桃| 资源县| 广州市| 蕲春县|