当新值为空或空时,Vue自动完成文本字段不会删除旧值

时间:2019-04-18 22:59:09

标签: javascript html vue.js asp.net-core vuex

我正在使用Vue,并且具有一个带有v-autocomplete field的表单

当我获取一个新的对象以填写表格时,如果当前字段具有某个值ex。 “旧金山”,并且该字段的新值是空白/空,然后该字段不会更新为空白字段,而是“旧金山”

我正在尝试确定它是否属于v-autocomplete field

<template>
  <v-container>
  <v-layout column style="position: fixed; top: 80px; right: 10px;">
            <v-btn @click="clickCloseBtn" fab small :disabled="!canClose"><v-icon>close</v-icon></v-btn>
            <v-btn @click="toggleEdit" fab small><v-icon v-if="!editMode">edit</v-icon><v-icon v-else="editMode" color="red">edit</v-icon></v-btn>
            <v-btn @click="goToFirst" fab small :disabled="!hasPrev"><v-icon>first_page</v-icon></v-btn>
            <v-btn @click="goToPrev" fab small :disabled="!hasPrev"><v-icon>chevron_left</v-icon></v-btn>
            <v-btn @click="goToNext" fab small :disabled="!hasNext"><v-icon>chevron_right</v-icon></v-btn>
            <v-btn @click="goToLast" fab small :disabled="!hasNext"><v-icon>last_page</v-icon></v-btn>
        </v-layout>
  <v-layout row wrap>
            <v-flex md2 px-1>
                <div class="subheader hover" @click="toggleExpandJobsite"><v-icon v-show="!expandJobsite" color="black">expand_more</v-icon><v-icon v-show="expandJobsite" color="black">expand_less</v-icon> Jobsite</div>
            </v-flex>
            <v-flex md3 px-1>
                <v-autocomplete v-model="jobsiteId"
                                :items="jobsiteCodeOptions"
                                :search-input.sync="jobsiteCodeSearch"
                                label="Jobsite Code"
                                @input="inputJobsiteCode"
                                clearable
                                hide-no-data
                                dense
                                :disabled="!editMode">
                </v-autocomplete>
            </v-flex>
            <v-flex md4 px-1>
                <v-text-field v-model="jobsiteName" label="Jobsite Name" disabled></v-text-field>
            </v-flex>
            <v-flex md3 px-1>
                <v-autocomplete v-model="locationId"
                                :items="locationNameOptions"
                                :search-input.sync="locationNameSearch"
                                label="Location Name"
                                @input="inputLocationName"
                                clearable
                                clear-icon
                                hide-no-data
                                dense
                                :disabled="!editMode || !jobsiteId">
                </v-autocomplete>
            </v-flex>
        </v-layout>
  </v-container>
</template>

在.vue中我有

export default {
  methods: {
    goToNext() {
      this.$router.push({
        path: '/Entry/Records/' + this.refList[this.refListIndex + 1].id
      })
    },
  }
}

这会调用控制器

    [HttpGet("{id}")]
    public IActionResult GetRecord([FromRoute] int id)
    {
       // stuff here ommitted

        var record = RecordsContext.GetRecord(_context, id);

       // other stuff ommitted

        return Ok(record);
    }

获取记录是

    public static Record GetRecord(MpidDbContext context, int id)
    {
        return context.Records.SingleOrDefault(m => m.Id == id);
    }

如果有询问,我可以显示“记录”!

0 个答案:

没有答案