我使用API来获取用户。我希望将用户绑定到b-form-select (引导-vue)。但是在请求之后,我在b-form-select中看到了"null“。我的请求
getAllUsers() {
axios.get('/GetUsers')
.then(res => {
this.funds = res.data
console.log(this.options1)
})
}以及显示数据的表单
<b-form-select
id="input-3"
v-model="userSelect"
:options="funds"
required
></b-form-select>但如果我用
<select v-model="userSelect" class="form-control">
<option v-for="user in funds" :key="user.id" :value="user">{{user.name }} {{user.id }}</option>
</select>我看到我的使用者了。为什么引导-vue不能显示我的数据?
发布于 2020-02-14 22:02:48
b--form-select从选项中将value作为值属性的默认字段,将text字段作为标签。
如果要自定义字段属性名称(例如,使用name字段显示文本),可以通过将文本字段、html字段、值字段和禁用字段道具设置为包含要使用的属性名称的字符串来轻松地更改它们:
<b-form-select
id="input-3"
v-model="userSelect"
:options="funds"
value-field="name"
text-field="name"
required
></b-form-select>https://stackoverflow.com/questions/60233721
复制相似问题