码迷,mamicode.com
首页 > 其他好文 > 详细

vue实现选中列表功能

时间:2018-06-14 01:08:12      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:computed   checkbox   sel   this   容量   列表功能   turn   exp   电信   

<template>
  <div>
    <ul v-for="prop in items">
        <dt>{{prop.name}}</dt>
        <dd v-for="op in prop.options">
             <input type="checkbox" :value="op" v-model="selectedProperties">{{op.value}}
        </dd>
    </ul>
  {{selectedProperties}}<br />
  {{foos}}
  </div>
</template>

<script>
export default {
  computed:{
    foos(){
      return this.selectedProperties.map(item => item.value);
    }
  },
  data() {
    return {
      selectedProperties: [],
      items: [
                    {
                        "name": "容量", "type": 1, "options": [
                            { "id": "1", "value": "64G" },
                            { "id": "2", "value": "256G" }
                        ]
                    },
                    {
                        "name": "颜色", "type": 1, "options": [
                            { "id": "3", "value": "金色" },
                            { "id": "4", "value": "红色" }
                        ]
                    },
                    {
                        "name": "网络类型", "type": 1, "options": [
                            { "id": "5", "value": "4G全网通" },
                            { "id": "6", "value": "4G电信" },
                            { "id": "7", "value": "4G移动" }
                        ]
                    },
                    {
                        "name": "套餐类型", "type": 1, "options": [
                            { "id": "8", "value": "普通套餐" },
                            { "id": "9", "value": "高级套餐" }
                        ]
                    }
                ]
    }
  }
    }

</script>

 

vue实现选中列表功能

标签:computed   checkbox   sel   this   容量   列表功能   turn   exp   电信   

原文地址:https://www.cnblogs.com/lwj820876312/p/9180710.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!