使用
<accessToType :type="scope.row.type" :list="['用户','商户','管理员','优选','企业']"></accessToType>
组件代码
/**
* @Author: 858834013@qq.com
* @Name: accessToType
* @Date: 2022-01-17
* @Desc: 根据列表获取并返回名称
*/
<template>
<div>
{{ TypeName }}
</div>
</template>
<script>
export default {
name: 'accessToType',
components: {},
props: {
list: {
type: Array,
default() {
return []
}
},
type: {
type: String | Array,
default() {
return ''
}
}
},
computed: {
TypeName: function() {
var typename = ''
this.list.forEach((type, index) => {
if (this.type == index) {
typename = type
}
})
return typename
}
}
}
</script>
<style lang="scss" scoped>
</style>