Bài viết phổ biến của tác giả
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用来自我的 API 的 v-select
thực hiện tùy chọn
,我将数据放在数组数组中。
Array which I got from API
它应该是一个带有搜索的 lựa chọn
,因为它的数据太多。
Đây là mã của tôi:
:items="categoriasProduto"
v-model="dadosProduto.id_marca"
item-text="nome"
item-value="id"
label="Marca"
>
脚本:
mounted() {
const url = process.env.VUE_APP_API_URL;
axios
.get(`${url}marcas/`)
.then((response) => {
this.marcas = response.data;
console.log(this.marcas);
});
},
有没有办法让它在
Vue
中工作?
1 Câu trả lời
如果你想包括搜索使用 v-autocomplete
.要遍历列表,请使用 .flat
:
new Vue({
el:"#app",
vuetify: new Vuetify(),
data: () => ({
categoriasProduto: [
[
{ id:1, id_simplus:'1', nome:'nome 1' },
{ id:2, id_simplus:'2', nome:'nome 2' },
],
[
{ id:3, id_simplus:'3', nome:'nome 3' },
{ id:4, id_simplus:'4', nome:'nome 4' },
]
],
dadosProduto: { id_marca: null }
}),
});
{{dadosProduto.id_marca}}
<>
:items="categoriasProduto.flat()"
v-model="dadosProduto.id_marca"
item-text="nome"
item-value="id"
label="Marca"
>
关于arrays - Vuetify : How to do a v-select search in array of arrays,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66284846/
Tôi là một lập trình viên xuất sắc, rất giỏi!