【问题标题】:How to change the b-input date type format?如何更改 b-input 日期类型格式?
【发布时间】:2019-08-17 11:37:20
【问题描述】:

我使用 bootstrap-vue b-inputtype='date',默认日期格式显示为 dd/MM/yyyy。如何将其更改为 dd-MM-yyyy?

<b-form-group :invalid-feedback="errors.first('birth_date')"
                  :state="!errors.has('birth_date')"
                  class="col-sm-4"
                  label="Birth Date"
                  label-for="new-employer-owner-birth-date">
      <b-input :state="!errors.has('birth_date')"
               id="new-employer-owner-birth-date"
               name="birth_date"
               type="date"
               v-model="newOwner.birth_date"
               v-validate.disable="validation.birth_date">
      </b-input>
    </b-form-group>

我在'type' 属性之后添加了:formatter="formatDate",但它也不起作用。

【问题讨论】:

    标签: bootstrap-4 vue-component


    【解决方案1】:

    newOwner.birth_date 的格式应为 YYYY-MM-DD

    如果你使用 moment(),你可以像这样格式化你的日期

    const unformattedDate = yourDate;
    
    newOwner.birth_date = moment(unformattedDate).format("YYYY-MM-DD");
    

    【讨论】:

      猜你喜欢
      • 2012-06-03
      • 1970-01-01
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多