在 b-form-select - Vue 中看不到 API 的值.js



>我使用 API 来获取用户。我希望将用户绑定到 b-form-select (bootstrap-vue(。但是在请求后,我在 b 表单选择中看到"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>

我看到了我的用户。为什么 bootstrap-vue 不能显示我的数据?

b--form-selectvalue作为选项中值属性的默认字段,并将text字段作为标签。

如果要自定义字段属性名称

(例如,使用名称字段显示文本(,可以通过将文本字段、html 字段、值字段和禁用字段属性设置为包含要使用的属性名称的字符串来轻松更改它们:

<b-form-select
id="input-3"
v-model="userSelect"
:options="funds"
value-field="name"
text-field="name"
required
></b-form-select>

最新更新