반응형
Bootstrap-Vue 텍스트 필드를 mm/dd/yyy 형식으로 변경하는 적절한 방법
Bootstrap-Vue를 사용하고 있습니다.<b-form-datepicker>컴포넌트 및 입력 날짜 필드를 커스터마이즈할 방법을 찾고 있습니다.mm/dd/yyyy포맷합니다.적절한 방법이 있나요?
<b-input-group class="mb-3">
<b-form-input
id="example-input"
v-model="dateOfBirth"
type="text"
placeholder="MM-DD-YYYY"
locale="en-US"
autocomplete="off"
></b-form-input>
<b-input-group-append>
<b-form-datepicker
v-model="dateOfBirth"
button-only
right
locale="en-US"
:date-format-options="{ year: 'numeric', month: 'short', day: '2-digit', weekday: 'short' }"
aria-controls="example-input"
></b-form-datepicker>
</b-input-group-append>
</b-input-group>
매뉴얼 https://bootstrap-vue.org/docs/components/form-datepicker
이 작업을 수행하려면 단순히 다음 작업을 할당해야 합니다.selectedFormatted로부터 값을 매기다.b-form-datepicker에v-model의 가치b-form-input.
참고: 둘 다 다른 v-model 값을 사용합니다.b-input-group&b-form-datepicker
데모:
new Vue({
el: '#app',
data() {
return {
value: '',
inputValue: ''
}
},
methods: {
onContext(ctx) {
this.inputValue = ctx.selectedFormatted;
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>
<link rel="stylesheet" href="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>
<link rel="stylesheet" href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<div id="app">
<label for="example-input">Choose a date</label>
<b-input-group class="mb-3">
<b-form-input
id="example-input"
v-model="inputValue"
type="text"
placeholder="MM/DD/YYYY"
autocomplete="off"
></b-form-input>
<b-input-group-append>
<b-form-datepicker
v-model="value"
button-only
right
locale="en-US"
aria-controls="example-input"
:date-format-options="{ year: 'numeric', month: 'numeric', day: 'numeric' }"
@context="onContext"
></b-form-datepicker>
</b-input-group-append>
</b-input-group>
</div>
각 구성 요소를 숫자로 설정하면 올바른 형식이 되지 않습니까?
<b-form-datepicker
:date-format-options="{ year: 'numeric', month: 'numeric', day: 'numeric' }"
locale="en"
></b-form-datepicker>
제공 내용:9/16/2020
언급URL : https://stackoverflow.com/questions/63911689/proper-way-to-change-bootstrap-vue-text-field-into-mm-dd-yyyy-format
반응형
'source' 카테고리의 다른 글
| 생성자에 super()를 넣을 필요가 없습니까? (0) | 2022.08.25 |
|---|---|
| 검출되지 않은 오류: [vuex] getters는 함수여야 하지만 "getters.default"는 {}입니다. (0) | 2022.08.25 |
| Vuejs에서 동적 요소와 함께 v-show를 사용하는 방법 (0) | 2022.08.25 |
| Vue-Devtools 쉘을 사용한 원격 디버깅 - net:ERR_CONNECTION_REFUSED (0) | 2022.08.25 |
| Vuex: Store에서 컴포넌트 데이터 또는 호출 컴포넌트 메서드를 업데이트하는 방법 (0) | 2022.08.24 |