我最近在学习VUEJS。我不能更进一步,因为我被困在一个问题上。问题:
我正在从一个api调用中获取一个列表。下面是这段代码:
<b-form-checkbox-group
v-model="authorize"
:options="authorize"
name="authorize"
stacked
text-field="name"
value-field="id"
>
我是使用.get('/authorize')
获得的,我有以下值:
[{"id":"country:list","name":"country:list"},{"id":"country:create","name":"country:create"},{"id":"user:retrieve","name":"user:retrieve"},{"id":"user:update","name":"country:update"},{"id":"country:destroy","name":"user:destroy"}]
在另一种形式中,我添加了其中的一些值,作为响应,我得到了这些值
[{"id":"country:list","name":"country:list"},{"id":"country:create","name":"country:create"},{"id":"user:retrieve","name":"user:retrieve"}]
我使用以下命令获得这些响应:
<b-form-checkbox-group
v-model="authorize"
:options="currentTutorial.authorize"
name="authorize"
stacked
text-field="name"
value-field="id"
>
但是我现在想要的是显示所有的authorize
列表以及保存的项目,但是那些保存的项目应该被选中,这是我在这里从currentTutorial.authorize
得到的
感谢你的帮助。谢谢
发布于 2021-03-19 03:13:30
<b-form-checkbox-group
v-model="authorize.id"
:options="authorize"
name="authorize"
stacked
text-field="name"
value-field="id"
>
你能像这样改变v-model变量吗?
https://stackoverflow.com/questions/66701993
复制相似问题