vue实现选中列表功能
Posted lwj820876312
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue实现选中列表功能相关的知识,希望对你有一定的参考价值。
<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实现选中列表功能的主要内容,如果未能解决你的问题,请参考以下文章