1.在一些列表中,会有下拉筛选,同时就会有对应的列表显示字段,枚举对应
bad
let dimensionTypeList = [
{
value: 'other',
label: '其他'
},
{
value: 'enterprise',
label: '企业'
},
{
value: 'staff',
label: '员工'
}
]
let dimensionStatus = {
'other': '其他',
'enterprise': '企业',
'staff': '员工'
}
good
let dimensionTypeList = [
{
value: 'other',
label: '其他'
},
{
value: 'enterprise',
label: '企业'
},
{
value: 'staff',
label: '员工'
}
]
computed: {
dimensionStatus () {
var dimensionStatus = {}
this.dimensionTypeList.map((item) => dimensionStatus[item.value] = item.label)
return dimensionStatus
}
}
这样就不用去维护两套代码了
- 如果关闭某个弹框,不用再去写事件 直接写就好了
<button type="button"
@click.stop="cancelReject" class="cancel-button">取消</button>
@click.stop="showing = false" class="cancel-button">取消</button>