el-select实现动态选择选项

首先data里面声明数组

 data() {
    return {
    	selectShop: [],
    }
 }

然后在el-option里面写到

 <el-option v-for="item in selectShop"
		      :key="item.id"
		       :value="item.id"
		       :label="item.name"
		      >

完整代码

 <el-form-item label="店铺:" :data="selectShop">
          <el-select
            class="dialogSelect"
            v-model="form.shopId"
            placeholder="选择店铺"
            clearable
          >
            <el-option v-for="item in selectShop"
             :key="item.id"
             :value="item.id"
             :label="item.name"
            >
            </el-option>
          </el-select>
        </el-form-item>

你可能感兴趣的:(笔记,vue)