Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

Vue:Duplicate keys detected This may cause an update error.

我明明设置了不同的key 为什么还是报这个错?

<a-auto-complete
            v-model="query"
            :allowClear="true"
            :backfill="true"
            placeholder="查询曲目/乐谱"
            optionLabelProp="title"
            class="search-box"
            @search="handleSearch"
            @blur="autoComplete = []"
          >
            <a-input>
              <a-button
                slot="suffix"
                class="search-btn"
                type="primary"
                style="margin-right: -12px"
                @click="searchPage"
              >
                <a-icon type="search" />
              </a-button>
            </a-input>
            <template slot="dataSource">
              <a-select-option
                class="option-item"
                v-for="item in autoComplete"
                :value="item.name"
                :key="`${item.name}_${item.id}`" //这里key不同**
                @click="jumpItem(item.id)"
              >
                <span>{{ item.name }}</span>
              </a-select-option>
            </template>
          </a-auto-complete>

把value设置为${item.name}_${item.id}以后不报错了
但是query的值就会变成${item.name}_${item.id}
不是name
我设置了a-select-option一个新属性:name="${item.name}_${item.id}"
以及optionLabelProp="name"
也不能正常回显name


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...