日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
微信小程序單選框如何自定義賦值

這篇文章主要為大家展示了微信小程序單選框如何自定義賦值,內(nèi)容簡(jiǎn)而易懂,希望大家可以學(xué)習(xí)一下,學(xué)習(xí)完之后肯定會(huì)有收獲的,下面讓小編帶大家一起來(lái)看看吧。

創(chuàng)新互聯(lián)專注于企業(yè)全網(wǎng)營(yíng)銷推廣、網(wǎng)站重做改版、五龍口網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5建站、商城建設(shè)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為五龍口等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。

知識(shí)點(diǎn):

1、理解wx:if作用
2、理解三元運(yùn)算符的使用
3、利用偽元素after/before自定義內(nèi)容
4、定時(shí)器setTimeout的使用

照例先上代碼

wxml部分:


 預(yù)計(jì)到店
 
 {{item}}
 


 


 
 
 房間整晚保留,14:00之前到店可能需要等房
 
  18:00以前
  
 
 
  20:00以前
  
 
 
  23:59以前
  
 
 
  次日凌晨6:00之前
  
 
 

wxss部分:

.input-list {
 padding: 40rpx;
 border-bottom: 1px solid #eee;
 display: flex;
 position: relative;
}

.list-l {
 flex: 2;
 line-height: 50rpx;
}

.list-r {
 flex: 5;
}

.arriveTime {
 line-height: 50rpx;
}

.drawer_screen { 
 width: 100%; 
 height: 100%; 
 position: fixed; 
 top: 0; 
 left: 0; 
 z-index: 1000; 
 background: #000; 
 opacity: 0.5; 
 overflow: hidden; 
} 
 
/*content*/
.drawer_box { 
 width: 100vw; 
 height: auto;
 padding: 0;
 overflow: hidden; 
 position: fixed; 
 bottom: 0; 
 left: 0; 
 z-index: 1001; 
 background: #fff; 
} 

.modalBox {
 padding: 0 40rpx;
 font-size: 30rpx;
}

.choosePush {
 text-align: center;
 padding: 40rpx 0 ;
 border-bottom: 1px solid #eee;
 position: relative
}

.choosePush.t {
 color: #1da0ee;
}

.checkbox {
 position: absolute;
 right: 0;
 top: 38rpx;
 height: 40rpx;
 width: 40rpx;
 border: 1px solid #1da0ee;
}

.checkbox::after {
 content: '';
 position: absolute;
 height: 15rpx;
 width: 25rpx;
 border-left: 1px solid #1da0ee;
 border-bottom: 1px solid #1da0ee;
 transform: rotate(-45deg);
 top: 6rpx;
 right: 6rpx;
}

js部分:

Page({

 data: {
 showModalStatus: false,
 _num: null,
 haveChoosed: false,
 sta: null,
 item: '18:00',
 },

 preventTouchMove() { },

 powerDrawer: function (e) {
 console.log(e)
 var currentStatu = e.currentTarget.dataset.statu;
 this.util(currentStatu)
 },
 util: function (currentStatu) {
 /* 動(dòng)畫(huà)部分 */
 // 第1步:創(chuàng)建動(dòng)畫(huà)實(shí)例 
 var animation = wx.createAnimation({
  duration: 200, //動(dòng)畫(huà)時(shí)長(zhǎng) 
  timingFunction: "linear", //線性 
  delay: 0 //0則不延遲 
 });

 // 第2步:這個(gè)動(dòng)畫(huà)實(shí)例賦給當(dāng)前的動(dòng)畫(huà)實(shí)例 
 this.animation = animation;

 // 第3步:執(zhí)行第一組動(dòng)畫(huà) 
 animation.opacity(0).translateY(500).step();

 // 第4步:導(dǎo)出動(dòng)畫(huà)對(duì)象賦給數(shù)據(jù)對(duì)象儲(chǔ)存 
 this.setData({
  animationData: animation.export()
 })

 // 第5步:設(shè)置定時(shí)器到指定時(shí)候后,執(zhí)行第二組動(dòng)畫(huà) 
 setTimeout(function () {
  // 執(zhí)行第二組動(dòng)畫(huà) 
  animation.opacity(1).translateY(0).step();
  // 給數(shù)據(jù)對(duì)象儲(chǔ)存的第一組動(dòng)畫(huà),更替為執(zhí)行完第二組動(dòng)畫(huà)的動(dòng)畫(huà)對(duì)象 
  this.setData({
  animationData: animation
  })

  //關(guān)閉 
  if (currentStatu == "close") {
  this.setData(
   {
   showModalStatus: false
   }
  );
  }
 }.bind(this), 200)

 // 顯示 
 if (currentStatu == "open") {
  this.setData(
  {
   showModalStatus: true
  }
  );
 }
 },

 chooseChecked: function (e) {
 console.log(e) //打印出來(lái)你會(huì)了解所設(shè)定參數(shù)的意義
 this.setData({
  _num: e.currentTarget.dataset.num,
  item: e.currentTarget.dataset.txt,
 })

 setTimeout(function () {
  this.setData(
  {
   showModalStatus: false
  }
  );
 }.bind(this), 2000)
 },


 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面加載
 */
 onLoad: function (options) {

 },

 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面初次渲染完成
 */
 onReady: function () {

 },

 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示
 */
 onShow: function () {

 },

 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面隱藏
 */
 onHide: function () {

 },

 /**
 * 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面卸載
 */
 onUnload: function () {

 },

 /**
 * 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽(tīng)用戶下拉動(dòng)作
 */
 onPullDownRefresh: function () {

 },

 /**
 * 頁(yè)面上拉觸底事件的處理函數(shù)
 */
 onReachBottom: function () {

 },

 /**
 * 用戶點(diǎn)擊右上角分享
 */
 onShareAppMessage: function () {

 }
})

這是單選效果,復(fù)選效果 獲取其index(如wxml中屬性設(shè)定為 data-selectIndex=''{{index}}'' , 在js方法中打印出來(lái)對(duì)象的json數(shù)組,利用三元運(yùn)算添加class屬性完成),點(diǎn)擊它自身時(shí),改變其狀態(tài),最后setData已改變屬性的json數(shù)組。

以上就是關(guān)于微信小程序單選框如何自定義賦值的內(nèi)容,如果你們有學(xué)習(xí)到知識(shí)或者技能,可以把它分享出去讓更多的人看到。


本文題目:微信小程序單選框如何自定義賦值
文章分享:http://www.dlmjj.cn/article/gghhdg.html