Skip to content

Commit

Permalink
fix: 修复时间选择器设置秒后,会导致获取的时间值异常
Browse files Browse the repository at this point in the history
  • Loading branch information
YufJi committed Nov 8, 2023
1 parent e2e2594 commit 64e53ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/datetime-picker/TimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ export default createComponent({
const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];

let innerValue = this.formatValue(`${hour}:${minute}`);
let innerValue = `${hour}:${minute}`;

if (this.unit === 'second') {
const second = secondColumn.values[secondIndex] || secondColumn.values[0];
innerValue += `:${second}`
}

this.innerValue = innerValue;
this.innerValue = this.formatValue(innerValue);
this.updateColumnValue();
},

Expand Down
4 changes: 4 additions & 0 deletions src/datetime-picker/demo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,20 @@
</demo-block>

<demo-block card :title="t('datetimeType')">
<div>value: {{value.datetime}}</div>
<van-datetime-picker :value.sync="value.datetime" type="datetime" :title="t('datetimeType')" />
</demo-block>
<demo-block card :title="t('datetimeType')">
<div>value: {{value.datetime}}</div>
<van-datetime-picker :value.sync="value.datetime" type="datetime" unit="minute" :title="t('datetimeType')" />
</demo-block>

<demo-block card :title="t('timeType')">
<div>value: {{value.time}}</div>
<van-datetime-picker :value.sync="value.time" type="time" :title="t('timeType')" />
</demo-block>
<demo-block card :title="t('timeType')">
<div>value: {{value.secondTime}}</div>
<van-datetime-picker :value.sync="value.secondTime" type="time" unit="second" :title="t('timeType')" />
</demo-block>
</demo-section>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6045,6 +6045,11 @@ decamelize@^1.1.0, decamelize@^1.1.2, decamelize@^1.2.0:
resolved "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz"
integrity "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA== sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA=="

decimal.js@^10.4.3:
version "10.4.3"
resolved "https://registry.yarnpkg.com/decimal.js/-/decimal.js-10.4.3.tgz#1044092884d245d1b7f65725fa4ad4c6f781cc23"
integrity sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==

decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz"
Expand Down

0 comments on commit 64e53ff

Please sign in to comment.