首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Vue-formulate Group item可折叠/切换折叠

Vue-formulate Group item可折叠/切换折叠
EN

Stack Overflow用户
提问于 2020-12-21 21:14:48
回答 1查看 194关注 0票数 -1

是否有可能使组项目可折叠?

代码语言:javascript
复制
        ....
    
    
    
        ....

我想加一句showForm属性设置为组上下文。

为此,我需要做自定义输入类型,或者有其他方法吗?

如果有人有其他想法的话?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-26 03:20:05

我明白了这一点,大意是@jpschroeder..。

CollapsableGroupItem.vue

代码语言:javascript
复制
export default {
    name: "CollapsableGroupItem",
    props: {
        context: {
            type: Object,
            required: true,
        },
        showIndex: {
            type: [Number, String],
            required: true,
        },
        groupItem: {
            type: Object,
            required: true,
        },
    },
    data () {
        return {
            itemId: this.context.name + this.context.index
        }
    },
    created: function () {
        // show current item
        this.$emit("open", this.itemId);
    },
    methods: {
        toggleBody() {
            if (this.itemId === this.showIndex) {
                // dont show anything
                this.$emit("open", -1);
            } else {
                // show this one
                this.$emit("open", this.itemId);
            }
        },
    }
};
</code></pre>
<p><strong>FormTemplate.vue</strong>:</p>
<pre><code><CollapsableGroupItem
    :context="context"
    :show-index="showIndex"
    :group-item="educations[context.index]"
    @open="showIndex = $event"
>   
    <template v-slot:title="education">
        <span v-if="education.institution || education.degree"
        >   
            {{ education.institution }}
            <span v-if="education.institution && education.degree">at</span>
            {{ education.degree }}
        </span>
        ...
    </template>
    <template v-slot:body>
        ...
    </template>
</CollapsableGroupItem>
</code></pre>
<p>Maybe it will help someone else or will be useful ?</p>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65393443

复制
相关文章

相似问题

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