V-Select和数据的问题
下午好朋友,然后我要告诉你我的错误。我正在为用户屏幕工作,您可以在其中进行注册和编辑。输入注册部分时,您不必在数据库中显示您已经扮演的角色。但是在编辑屏幕上,它已经分配了一个角色,因此我必须将其带入它(就像文本场一样),但我无法将其加载。 屏幕的附加图像:
进入屏幕后立即进行调试器时,我意识到它正在返回作为数组的角色。它很好地向我展示了角色,但它并没有将其放在选择中。 图像下方的错误图像是我使用的代码。
<v-select
label="Rol"
v-model="form.rolId"
:items="roles"
item-value="value"
item-text="text"
:rules="[(v) => !!v || 'Este campo es requiredo']"
required
>
</v-select>
data() {
return {
form: {},
roles: [
{ value: "Agente", text: "Agente" },
{ value: "Administrador", text: "Administrador" },
],
};
},
Good afternoon friends, then I'm going to tell you my mistake. I am working for a users screen, where you have your registration and editing. When you enter the register section you don't have to show the role you already have in the database. But on the edit screen, it already has a role assigned, so I would have to bring it to it (as it does with the text-fields) But I can't get it to load them.
attached images of the screen:
When I do a debugger as soon as I enter the screen, I realize that it is returning the roles as an array. And it shows me the role well, but it doesn't place it in the select.
Attached image of the error, below the images is the code that I use.
<v-select
label="Rol"
v-model="form.rolId"
:items="roles"
item-value="value"
item-text="text"
:rules="[(v) => !!v || 'Este campo es requiredo']"
required
>
</v-select>
data() {
return {
form: {},
roles: [
{ value: "Agente", text: "Agente" },
{ value: "Administrador", text: "Administrador" },
],
};
},
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在V-Model上放置一个默认值,以使其在选择中加载数据。
请参阅此处的Codepen
You have to put a default value on your v-model for it to load the data in the select.
see codepen here