当前位置: 首页>编程语言>正文

element date-picker解决周数获取问题(ISOWEEK)

鍦ㄤ娇鐢╡lement date-picker缁勪欢鏃跺彂鐜板懆鏁拌幏鍙栭棶棰?濡備笅
濡?褰撳墠濡傛湡涓?021/10/08
date-picker鏄剧ず鍛ㄦ暟涓?code>202040

element date-picker解决周数获取问题(ISOWEEK),第1张

杩欎釜鍛ㄦ暟202040鏄疘SOWEEK鍛ㄦ暟,鑰屾垜浠悗绔娇鐢ㄧ殑鏄潪ISOWEEK鍛ㄦ暟涓?code>202041
濡傛灉姝ゆ椂浣犻渶瑕佺殑鍒氬ソ鏄?code>ISOWEEK鍛ㄦ暟,鍙互鐩存帴浣跨敤,濡傛灉鎯虫嬁鍒?code>闈濱SOWEEK鍛ㄦ暟,璇ュ浣曞鐞唦,鏈互涓篹lement浼氭彁渚?鎵句簡鍗婂ぉ娌℃壘鍒?鏈夌煡閬撶殑鏈嬪弸鍙互涓嬫柟鐣欒█鍛婅瘔鎴?鎰熻阿!!!

涓嬮潰鏄垜鑾峰彇闈濱SOWEEK鍛ㄦ暟鐨勫鐞嗘柟寮忦煈?/p>

瀹炵幇鏂规

閫氳繃moment(val).week() 鍙互鑾峰彇褰撳墠val鏃ユ湡闈濱SOWEEK鍛ㄦ暟
鑾峰彇闈濱SOWEEK鍛ㄦ暟鍚庡啀璧嬪€肩粰date-picker

1.瀹夎moment,姝ゅ鐪佺暐
2.缁欏嚭dom

<span id="currentWeekly" >
     <el-date-picker  v-model='dataStart' size="small" :clearable='false' :format='dateFormat'  type="week"  v-on:change='dateStart'></el-date-picker>
</span>

$('#currentWeekly input')鍙互鎷垮埌date-picker鏄剧ず鍊?鍚屾牱涔熷彲浠ヨ祴鍊?br> 3.閫昏緫澶勭悊

  var nowWeek = new Date();
  var dateVue = new Vue({
    el: el,
    data: {
      dataStart: nowWeek,
    },
    created() { },
    mounted(){
      //鍒濆鏄剧ず褰撳墠鏃堕棿闈濱SOWEEK鍛ㄦ暟
      $('#currentWeekly input').val(moment().isoWeekYear() + 'w' + moment(nowWeek).week())
    },
    computed: {
      dateFormat: function (day) {
        return 'yyyy[w]WW';
      },
    },
    watch: {
      dataStart(newVal, oldVal) {
        //change浜嬩欢涓幏鍙杁ate-picker鍊?
        this.$nextTick(() => {
          //鑾峰彇褰撳墠闈濱SOWEEK鍛ㄦ暟
          $('#currentWeekly input').val(moment().isoWeekYear() + 'w' + moment(newVal).week())
          
        })
      },
    },
    methods: {
      
    },
  });

娉ㄦ剰鏈€缁堝彇鍊间笉鑳戒粠dataStart涓幏鍙栦簡,浣跨敤$('#currentWeekly input').val()鑾峰彇鏈€缁堢粨鏋?/p>


https://www.xamrdz.com/lan/5zb1994102.html

相关文章: