如何更改b输入日期类型格式?

时间:2019-03-27 00:33:42

标签: bootstrap-4 vue-component

我将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>

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

1 个答案:

答案 0 :(得分:0)

  

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

如果您使用moment(),则将日期格式设置为

const unformattedDate = yourDate;

newOwner.birth_date = moment(unformattedDate).format("YYYY-MM-DD");
相关问题