bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

微信小程序單選框如何自定義賦值

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

創新互聯專注于企業全網營銷推廣、網站重做改版、五龍口網站定制設計、自適應品牌網站建設、H5建站商城建設、集團公司官網建設、外貿網站制作、高端網站制作、響應式網頁設計等建站業務,價格優惠性價比高,為五龍口等各大城市提供網站開發制作服務。

知識點:

1、理解wx:if作用
2、理解三元運算符的使用
3、利用偽元素after/before自定義內容
4、定時器setTimeout的使用

照例先上代碼

wxml部分:

<view class='input-list'>
 <view class='list-l'>預計到店</view>
 <view class='list-r' bindtap='powerDrawer' data-statu="open">
 <view class='arriveTime'>{{item}}</view>
 </view>
</view>

<view class="drawer_screen" wx:if="{{showModalStatus}}" bindtap="powerDrawer" data-statu="close" catchtouchmove="preventTouchMove"></view> 
<!--content-->
<!--使用animation屬性指定需要執行的動畫-->
<view animation="{{animationData}}" class="drawer_box" wx:if="{{showModalStatus}}" catchtouchmove="preventTouchMove"> 
 <view class='modalBox'>
 <view class='choosePush grey9'>房間整晚保留,14:00之前到店可能需要等房</view>
 <view class="{{_num == 0 &#63; 'choosePush t' : 'choosePush'}}" bindtap='chooseChecked' data-num='0' data-txt='18:00以前'>
  18:00以前
  <view class='checkbox' wx:if="{{_num==0}}"></view>
 </view>
 <view class="{{_num == 1 &#63; 'choosePush t' : 'choosePush'}}" bindtap='chooseChecked' data-num='1' data-txt='20:00以前'>
  20:00以前
  <view class='checkbox' wx:if="{{_num==1}}"></view>
 </view>
 <view class="{{_num == 2 &#63; 'choosePush t' : 'choosePush'}}" bindtap='chooseChecked' data-num='2' data-txt='23:59以前'>
  23:59以前
  <view class='checkbox' wx:if="{{_num==2}}"></view>
 </view>
 <view class="{{_num == 3 &#63; 'choosePush t' : 'choosePush'}}" bindtap='chooseChecked' data-num='3' data-txt='次日凌晨6:00之前'>
  次日凌晨6:00之前
  <view class='checkbox' wx:if="{{_num==3}}"></view>
 </view>
 </view>
</view>

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) {
 /* 動畫部分 */
 // 第1步:創建動畫實例 
 var animation = wx.createAnimation({
  duration: 200, //動畫時長 
  timingFunction: "linear", //線性 
  delay: 0 //0則不延遲 
 });

 // 第2步:這個動畫實例賦給當前的動畫實例 
 this.animation = animation;

 // 第3步:執行第一組動畫 
 animation.opacity(0).translateY(500).step();

 // 第4步:導出動畫對象賦給數據對象儲存 
 this.setData({
  animationData: animation.export()
 })

 // 第5步:設置定時器到指定時候后,執行第二組動畫 
 setTimeout(function () {
  // 執行第二組動畫 
  animation.opacity(1).translateY(0).step();
  // 給數據對象儲存的第一組動畫,更替為執行完第二組動畫的動畫對象 
  this.setData({
  animationData: animation
  })

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

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

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

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


 /**
 * 生命周期函數--監聽頁面加載
 */
 onLoad: function (options) {

 },

 /**
 * 生命周期函數--監聽頁面初次渲染完成
 */
 onReady: function () {

 },

 /**
 * 生命周期函數--監聽頁面顯示
 */
 onShow: function () {

 },

 /**
 * 生命周期函數--監聽頁面隱藏
 */
 onHide: function () {

 },

 /**
 * 生命周期函數--監聽頁面卸載
 */
 onUnload: function () {

 },

 /**
 * 頁面相關事件處理函數--監聽用戶下拉動作
 */
 onPullDownRefresh: function () {

 },

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

 },

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

 }
})

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

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

分享標題:微信小程序單選框如何自定義賦值
瀏覽路徑:http://vcdvsql.cn/article16/gghhdg.html

成都網站建設公司_創新互聯,為您提供服務器托管網站排名外貿建站網站建設微信小程序網站制作

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

營銷型網站建設