uni-app中組件picker的基本使用(日期選擇器為例)


例:需要在下圖“自定義日期”中使用日期選擇器

<template>
  <div>
    <picker mode="date" @change="bindDateChange">
      <div :class="timeIndex == 4 ? 'active-time' : ''">{{anyDate}}</div>
    </picker>
  </div>
</template>

<script>
  export default {
    data(){
      return {
	timeIndex:0,
	anyDate:'自定義日期'
      }
     },
      methods:{
	bindDateChange (e) {
	  console.log(e)
	  this.anyDate = e.detail.value
	  this.timeIndex = 4
	},
	changeTime(index) {
	  this.timeIndex = index
	  this.anyDate = '自定義日期'
	  }
	}
  }
</script>

效果圖:(單獨分出來編輯的)點擊自定義日期后顯示一下效果,顏色切換為藍色,當點擊圖一中的其他按鈕時被點擊的按鈕顏色發生切換,自定義按鈕顏色會回復默認(以上代碼顯示僅如下圖所示)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM