提交表格或发布请求后错过的匹配日期

时间:2020-06-23 14:34:40

标签: javascript vue.js vuetify.js v-data-table

我有以下date-picker实现

v-row>
                <v-col cols="12" sm="6" md="4" class="mr-12">
                      <v-menu
                        v-model="menu1"
                        :close-on-content-click="false"
                        transition="scale-transition"
                        offset-y
                        min-width="290px"
                      >
                        <template v-slot:activator="{ on }">
                          <v-text-field
                            v-model="startDate"
                            label="Start Date"  
                            prepend-icon="event"
                            readonly
                            v-on="on"
                          ></v-text-field>
                        </template>
                        <v-date-picker v-model="startDate" no-title scrollable
                          @input="menu1 = false"
                        >
                        </v-date-picker>
                      </v-menu>
                </v-col>
                <v-col cols="12" sm="6" md="4" class="ml-12 pl-2">
                      <v-menu
                        v-model="menu2"
                        :close-on-content-click="false"
                        transition="scale-transition"
                        offset-y
                        min-width="290px"
                      >
                        <template v-slot:activator="{ on }">
                          <v-text-field
                            v-model="endDate"
                            label="End Date"  
                            prepend-icon="event"
                            readonly
                            v-on="on"
                          ></v-text-field>
                        </template>
                        <v-date-picker v-model="endDate" no-title scrollable
                          @input="menu2 = false"
                        >
                        </v-date-picker>
                      </v-menu>
                </v-col>
              </v-row>

data () {
  return {
    startDate:null,
    endDate: null,
    menu1: false,
    menu2: false,
  }

Left part is after post request i.e response, and console is the one before submitting 我要求发布此数据,但是在提交数据之前,我具有正确的日期格式,但是在提交后,我会错过与日期匹配的格式。在图像中,左侧是发布请求(即响应)之后的内容,控制台是提交之前的内容。这是来自后端的问题吗?我不知道后端部分。

编辑:

我尝试通过以下方式设置日期格式:

format_date(date){
    const [, month, day, year] = date.split(' ')
    const ddMmmYyyy = [day, month, year].join('-')
    
    return ddMmmYyyy

这似乎不起作用。这是格式化日期的正确方法吗?

0 个答案:

没有答案