xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

vue computed pass params All In One

vue computed pass params All In One

vue computed pass parameter

js clousure

js 闭包

<template>
    <section class="vertical-video-9vs16-container">

    <!-- 多组创意文案-->
    <el-form-item>
        <div slot="label">
            <span class="c-red">*&nbsp;</span>创意文案
        </div>
        <section class="text-add-group-container">
            <section
                class="text-add-group-boxs"
                v-for="(item, index) in textGroupList"
                :key="(index)">
                <div class="text-add-group-box">
                    <el-form-item
                        label=""
                        :prop="`creativeList.${creativeIndex}.descList.${index}`"
                        :rules="[
                            {
                                required: true,
                                validator: descListValidator,
                                trigger: 'blur',
                            },
                        ]">
                        <CreativeTexts
                            ref="creativeTextsRef"
                            :titleIndex="index"
                            titleType="descList"
                            :creativeObj="creativeObj"
                            :customWords="customWords"
                            :sensitiveList="sensitiveList"
                            :prohibitedList="prohibitedList"
                            @validate-field="validateFieldByKey"
                            @open-title-type="openTitleLibraryModal('descList', index)"
                        />
                    </el-form-item>
                    <div
                        v-if="textGroupList.length > 1"
                        class="delete-icon-box">
                        <div>
                            <icon-svg
                                icon-class="delete"
                                class="delete-icon"
                                @click="removeDescGroup(index)"
                            />
                        </div>
                    </div>
                </div>
                <el-form-item
                    v-if="isShowDescListSensitives(index)"
                    class="creative-text-input-warning-box"
                    label="">
                    <div class="creative-text-input-warning">
                        <el-alert
                            type="warning"
                            :closable="false"
                            :title="`包含敏感词:${getDescListSensitives(index)}`">
                        </el-alert>
                    </div>
                </el-form-item>
            </section>
            <div
                v-if="leftNum > 0"
                class="add-group-btn-box"
                @click="addDescGroup">
                <span class="add-group-btn-text">
                    <icon-svg icon-class="tianjia1" />
                    <span>还可以添加{{leftNum}}组</span>
                </span>
            </div>
        </section>
    </el-form-item>


    </section>
</template>
export default {
    name: 'VerticalVideo9vs16',
    computed: {
        isShowTitleListSensitives () {
            return this.creativeObj.titleList[0].sensitiveList.length > 0;
        },
        isShowDescListSensitives () {
            // ES5 Function ✅ this
            return function (index) {
                return this.creativeObj.descList[index].sensitiveList.length > 0;
            };
            // ES6 Arrow Function ??? this bug ❌
            return  (index) => {
                return this.creativeObj.descList[index].sensitiveList.length > 0;
            };
        },
    },,
    mounted () {
        this.init();
    },
    methods: {
        init () {
            //
        },
    },
};


computed: {
   fullName() {
      return salut => `${salut} ${this.firstName} ${this.lastName}`
   }
}

refs

https://stackoverflow.com/questions/40522634/can-i-pass-parameters-in-computed-properties-in-vue-js



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-08-12 20:54  xgqfrms  阅读(71)  评论(0编辑  收藏  举报