鍍金池/ 問(wèn)答/HTML5  HTML/ iview 中使用for渲染select,設(shè)置model的值為數(shù)組

iview 中使用for渲染select,設(shè)置model的值為數(shù)組

clipboard.png
v-for循環(huán)中,如何讓select 的v-model變成數(shù)組的形式,因?yàn)槲疫@邊需要設(shè)置是否多選

回答
編輯回答
檸檬藍(lán)
<template>
    <i-select :model.sync="model10" multiple style="width:260px">
        <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
    </i-select>
</template>
<script>
    export default {
        data () {
            return {
                cityList: [
                    {
                        value: 'beijing',
                        label: '北京市'
                    },
                    {
                        value: 'shanghai',
                        label: '上海市'
                    },
                    {
                        value: 'shenzhen',
                        label: '深圳市'
                    },
                    {
                        value: 'hangzhou',
                        label: '杭州市'
                    },
                    {
                        value: 'nanjing',
                        label: '南京市'
                    },
                    {
                        value: 'chongqing',
                        label: '重慶市'
                    }
                ],
                model10: []
            }
        }
    }
</script>

官方文檔鏈接描述

2018年6月2日 20:49