uniapp computed进行类型计算显示组件 getType

uniapp yekong 913℃

代码

/**
* @Author: 858834013@qq.com
* @Name: getType
* @Date: 2022-04-28
* @Desc: 类型过滤 SendBill-派车单 OrderBill-订单 PaymentBill-缴费单 AdjustPriceBill-调价单
*/
<template>
	<div class="getType">
		{{name}}
	</div>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					title: '派车单',
					id: 'SendBill'
				}, {
					title: '订单',
					id: 'OrderBill'
				}, {
					title: '缴费单',
					id: 'PaymentBill'
				}, {
					title: '调价单',
					id: 'AdjustPriceBill'
				}]
			}
		},
		props: {
			value: {
				type: String,
				default () {
					return '';
				}
			},
		},
		computed: {
			name: function() {
				var name = ''
				this.list.forEach((type) => {
					if (this.value == type.id) {
						name = type.title
					}
				});
				return name
			}
		}
	}
</script>
<style scoped lang="scss">
	.getType {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #454675;
	}
</style>

使用

<getType :value="item.BillType"></getType>
喜欢 (0)