omim - dynamic import locale data

This commit is contained in:
dntzhang 2019-06-19 08:14:51 +08:00
parent eac4bb9fef
commit ea8e0225c3
2 changed files with 15 additions and 3 deletions

View File

@ -3,8 +3,12 @@ import css from './index.scss'
import '../icon'
import '../input'
interface Props {
lan: string
}
@tag('m-date-picker')
class DatePicker extends WeElement<{}, {}> {
class DatePicker extends WeElement<Props, {}> {
static css = css
@ -22,6 +26,14 @@ class DatePicker extends WeElement<{}, {}> {
}
locale: any
installed() {
import('./locale/' + this.props.lan).then((locale) => {
this.locale = locale
this.update(true)
})
}
initCurrentDate() {
if (this.selectedDate) {
this.dateArr = this.selectedDate.split('-')
@ -147,7 +159,7 @@ class DatePicker extends WeElement<{}, {}> {
{props.show && <div class='_ctn'>
<div class="_header">
<div style="position: relative;">
<a class="prev-year-btn" role="button" title="上一年" onClick={this.gotoPreYear}></a>
<a class="prev-year-btn" role="button" title="上一年" onClick={this.gotoPreYear}></a>
<a class="prev-month-btn" role="button" title="上个月" onClick={this.gotoPreMonth}></a>
<span class="ym-select">
<a class="year-select" role="button" title="选择年份">{this.year}</a>

View File

@ -1,5 +1,5 @@
export default {
defineLocale: function (locale, data) {
return { [locale]: data }
return data
}
}