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