vue项目:点击按钮新增一个input输入框

  • Post author:
  • Post category:vue


vue项目:点击按钮新增一个input输入框

<template>
	<div>
		<el-button type="primary" @click="addInput" :disabled="pointList.length >= 10">新增输入框</el-button>
		<div
            v-for="(item, index) in pointList"
            :key="index"
        >
        <el-input
            class="w400"
            placeholder="请输入推广卖点(6-9个字)"
            v-model="pointList[index]"
            maxlength="9"
            show-word-limit
        >
            <el-button
                v-show="pointList.length > 1"
                slot="append"
                icon="el-icon-delete"
                @click="deletePoint(index)"
            ></el-button>
        </el-input>
        </div>
	</div>
</template>
data () {
	return {
		pointList[""]
	}
},
methods: {
	addInput () {
            this.pointList.push("")
        },
    deletePoint (index) {
        this.pointList.splice(index, 1)
    }
}
       



版权声明:本文为qq_37953045原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。