代码如下:
<my_select v-bind:select_db="['A','B','C']"></my_select>
<template id="select_template">
<select class="form-control" id="customer">
<option value="0">--請選擇--</option>
<option v-for="(item,key) in select_db" value="@{{key}}">@{{ item }}:@{{ key }}</option>
</select>
</template>
<script>
Vue.component('my_select',{
template:'#select_template',
props:['select_db']
});
</script>
得到的HTML如下:
<select id="customer" class="form-control">
<option value="0">--請選擇--</option>
<option value="{{key}}">A:0</option>
<option value="{{key}}">B:1</option>
<option value="{{key}}">C:2</option>
</select>
请问,如何能得让select中value=key
非常感谢~
<option v-for="(item,key) in select_db" value="{{key}}">{{ item }}:{{ key }}</option>