首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用for循环验证网格系统

使用for循环验证网格系统
EN

Stack Overflow用户
提问于 2019-08-29 06:48:03
回答 1查看 451关注 0票数 1

Vue版本: 2.6.10

验证版本: 1.5

此时,我在不同的行中获取for循环中的每一项。如果只有2个项目,我想让它们排成一行。如果是3-4项-2行,依此类推。

我的代码:

代码语言:javascript
复制
<template v-slot:expand="props">
                    <v-card flat>
                        <v-card flat="flat" color="dark">
                            <v-container fluid="fluid" grid-list-xl="grid-list-xl">
                                <v-layout row>
                                    <v-flex xs8>Position and workload: </v-flex>
                                    <v-flex xs4>Categories: </v-flex>
                                </v-layout>
                                <v-layout row>
                                    <v-flex xs3>
                                        <template v-for="(position, pindex) in props.item.position">
                                            <v-text-field v-bind:key="pindex" class=" expandable" type="text" size="45"
                                                style="float:right" v-model="position.position" />
                                        </template>
                                    </v-flex>
                                    <v-flex xs1>
                                        <template v-for="(workload, windex) in props.item.workload">
                                            <v-text-field v-bind:key="windex" class="expandable" type="text" size="5"
                                                style="float:left" v-model="props.item.workload[windex]" />
                                        </template>
                                    </v-flex>
                                    <v-spacer></v-spacer>
                                    <v-flex xs4>
                                        <div>
                                            <v-text-field class="expandable" type="text"
                                                v-model="props.item.categories" />
                                        </div>
                                    </v-flex>
                                </v-layout>
                            </v-container>
                        </v-card>
                    </v-card>
                </template>

此时,输出如下:

想要的输出:

EN

回答 1

Stack Overflow用户

发布于 2019-08-29 15:38:05

部分回答代码。所有到某一行,第3行,第4行,以此类推的元素,都不会到更低的行。如果我使用的是wrap“类别将会更低而不是位置。

代码语言:javascript
复制
  <template v-slot:expand="props">
                    <v-card flat>
                        <v-card flat="flat" color="dark">
                            <v-container fluid="fluid" grid-list-xl="grid-list-xl">
                                <v-layout row>
                                    <v-flex xs8>Pareigos ir krūvis: </v-flex>
                                    <v-flex xs4>Kategorijos: </v-flex>
                                </v-layout>
                                <v-layout row>
                                    <template v-for="pindex in props.item.position.length">
                                        <v-flex xs3>
                                            <v-text-field class=" expandable" type="text" size="45" style="float:right"
                                                v-model="props.item.position[pindex - 1].position" />
                                        </v-flex>
                                        <v-flex xs1>
                                            <v-text-field class="expandable" type="text" size="5" style="float:left"
                                                v-model="props.item.workload[pindex - 1]" />
                                        </v-flex>
                                    </template>
                                    <v-spacer> </v-spacer>
                                    <v-flex xs4>
                                        <div>
                                            <v-text-field class=" expandable" type="text"
                                                v-model="props.item.categories" />
                                        </div>
                                    </v-flex>
                                </v-layout>
                            </v-container>
                        </v-card>
                    </v-card>
                </template>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57700912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档