给id属性用v-bind动态绑定对象和字符串

class和id 动态的绑定一个字符串达到自定义名称的方法::class="'字符串'+item. value"  :id="'字符串'+item. value"

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>分配</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <script src="https://cdn.jsdelivr.net/npm/vue"></script>
  <style type="text/css">
 table{border:#ccc 0px solid; margin:0px auto;}
 th{height:40px; line-height:40px; border-bottom:#ccc 1px solid;}
 td{height:30px; line-height:30px; border-bottom:#ccc 1px solid; font-size:12px;}
  </style>
</head>
<body>
<div id="app" style="width:1000px; overflow: auto; margin:0px auto">
<table  width="1000" border="0" cellspacing="0" cellpadding="0">
  <thead>
    <tr>
      
      <th width="150" align="center">区域</th>
      <th width="150" align="center">店</th>
      <th  align="center">组</th>
    </tr> 
  </thead>
  <tbody>
    <tr v-for="(item,index) in res">
      
      <td align="center">{{item.area}}</td>
      <td align="center">{{item.store}}</td>
      <td align="left">
      <span  v-for="(items,indexs) in item.group"><input type="radio" name="group" :value="items.group_id" :id="'group'+items.group_id"><label :for="'group'+items.group_id">{{items.group_name}}{{items.people_num}}人[{{items.manager}}]</label></span>
      
     </td>
    </tr>




    
  </tbody>
</table>
</div>
<script>
new Vue({
  el:"#app",
  data:{
    res:[
    {
        "area":"唐山地区",
        "area_id":"10",
        "store":"凤凰园店",
        "store_id":"11",
        "nature":"1",
        "group":[
            {
                "group_name":"B组",
                "manager":"李凯旋",
                "people_num":"18",
                "group_id":"120"
            },
            {
                "group_name":"C组",
                "manager":"靳国强",
                "people_num":"10",
                "group_id":"121"
            },
            {
                "group_name":"E组",
                "manager":"张少龙",
                "people_num":"7",
                "group_id":"122"
            }
        ]
    },
    {
        "area":"唐山地区",
        "area_id":"20",
        "store":"天元骏景店",
        "store_id":"21",
        "nature":"1",
        "group":[
            {
                "group_id":"123",
                "group_name":"A组",
                "manager":"刘海生",
                "people_num":"16"
            },
            {
                "group_id":"124",
                "group_name":"C组",
                "manager":"殷志豪",
                "people_num":"11"
            },
            {
                "group_id":"125",
                "group_name":"D组",
                "manager":"张硕",
                "people_num":"5"
            }
        ]
    }
]
  }
});
</script>
</body>

</html>

具体方法可以参考:http://blog.csdn.net/xiongmaodeguju/article/details/78526594###;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值