vue 实现多选

v-model

<template>
    <!--用户页面-选择关注-->
    <div class="follow">
        <h4>选择关注</h4>
        <p>请选择您感兴趣的分类,给您最精准的推荐</p>
        <div>
            <ul class="flexStart">
                <li v-for="(item,index) in followLists" :key="index">
                    <input type="checkbox" :id="item.id" :value="item.id" v-model="selectedIndex"/>
                    <label :for="item.id" class="choice-item">{{item.txt}}</label> 
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'userFollow',
        data() {
            return {
                selectedIndex: [],
                followLists: [
                    {id: 0, txt: '入职体检'},
                    {id: 1, txt: '入职体检'},
                    {id: 2, txt: '入职体检'},
                    {id: 3, txt: '入职体检'},
                    {id: 4, txt: '入职体检'}
                ]
            }
        }
    }
</script>

<style scoped>
    h4 {
        font-size: 18px;
    }
    .follow {
        padding: 30px 0 0 10px;
        float: left;
        width: 400px;
        color: #0c0c0c;
    }
    .follow h4 {
        color: #358ee7;
    }
    .follow p {
        margin-bottom: 12px;
    }
// 隐藏input .follow ul li input { display: none; }
// 设置lable样式 .choice-item { float: left; width: 120px; height: 36px; line-height: 36px; text-align: center; border-left: 6px solid #d6d6d6; background-color: #eaeaea; margin-bottom: 16px; margin-right: 10px; cursor: pointer; }
// 设置选中项label样式
input:checked + .choice-item { color: #fff; border-left: 6px solid #0a69c7; background-color: #358ee7; } </style>

 

转载于:https://www.cnblogs.com/duanzhenzhen/p/10604657.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值