element-ui select

1. 组合 label

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>

<body>
    <div id="app">
        <el-select v-model="options[0].value" placeholder="请选择">
            <!-- <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                <template slot-scope></template>
            </el-option> -->
            <el-option v-for="(item,index) in options" :key="index" :label="`${item.label}-${item.value}`" :value="item.value">
                    <!-- <template slot-scope></template> -->
                </el-option>
        </el-select>
    </div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function () {
            return {
                options: [{
                    value: '1556445455525',
                    label: 'afsdsdsiosiodidsu',
                    num:'选项1'
                }, {
                    value: '2556445455525',
                    label: 'bfsdsdsiosiodidsu',
                    num:'选项2'
                }, {
                    value: '3556445455525',
                    label: 'cfsdsdsiosiodidsu',
                    num:'选项3'
                }],
                value: ''
            }
        }    
    })
</script>

</html>
View Code

猜你喜欢

转载自www.cnblogs.com/justSmile2/p/11318612.html