1.引入字典
bash
dicts: ['order_status','product_type'],
2.表单中使用
select下拉
cpp
<el-form-item label="订单状态" prop="orderStatus">
<el-select v-model="form.orderStatus" clearable placeholder="请输入订单状态" :disabled="isDisable" style="width: 100%" >
<el-option
v-for="dict in dict.type.order_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
checkbox
cpp
<el-form-item label="是否正式报价单" prop="isFormal">
<el-radio-group v-model="form.isFormal">
<el-radio v-for="dict in dict.type.yes_or_no" :key="dict.value" :label="dict.value">{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
3.列表中使用
cpp
<el-table-column label="订单状态" align="center" prop="orderStatus" >
<template slot-scope="scope">
<dict-tag :options="dict.type.order_status" :value="scope.row.orderStatus"/>
</template>
</el-table-column>