fix(Calendar): rendering error when activated (#5978)

This commit is contained in:
neverland 2020-04-01 20:27:32 +08:00 committed by GitHub
parent 537e80e37a
commit 0698872285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 14 deletions

View File

@ -176,7 +176,7 @@ export default {
if (date === 1) { if (date === 1) {
day.topInfo = '劳动节'; day.topInfo = '劳动节';
} else if (date === 4) { } else if (date === 4) {
day.topInfo = '五四青年节'; day.topInfo = '青年节';
} else if (date === 11) { } else if (date === 11) {
day.text = '今天'; day.text = '今天';
} }

View File

@ -122,7 +122,7 @@ export default {
out: '离店', out: '离店',
today: '今天', today: '今天',
laborDay: '劳动节', laborDay: '劳动节',
youthDay: '五四青年节', youthDay: '青年节',
calendar: '日历', calendar: '日历',
maxRange: '日期区间最大范围', maxRange: '日期区间最大范围',
selectCount: count => `选择了 ${count} 个日期`, selectCount: count => `选择了 ${count} 个日期`,

View File

@ -135,13 +135,7 @@ export default createComponent({
watch: { watch: {
type: 'reset', type: 'reset',
value: 'init',
value(val) {
if (val) {
this.initRect();
this.scrollIntoView();
}
},
defaultDate(val) { defaultDate(val) {
this.currentDate = val; this.currentDate = val;
@ -150,10 +144,11 @@ export default createComponent({
}, },
mounted() { mounted() {
if (this.value || !this.poppable) { this.init();
this.initRect(); },
this.scrollIntoView();
} activated() {
this.init();
}, },
methods: { methods: {
@ -163,7 +158,11 @@ export default createComponent({
this.scrollIntoView(); this.scrollIntoView();
}, },
initRect() { init() {
if (this.poppable && !this.value) {
return;
}
this.$nextTick(() => { this.$nextTick(() => {
// add Math.floor to avoid decimal height issues // add Math.floor to avoid decimal height issues
// https://github.com/youzan/vant/issues/5640 // https://github.com/youzan/vant/issues/5640
@ -172,6 +171,7 @@ export default createComponent({
); );
this.onScroll(); this.onScroll();
}); });
this.scrollIntoView();
}, },
// scroll to current month // scroll to current month