<template>
<div>{{ phoneNumber | maskPhone }}</div>
</template>
<script setup>
import { ref } from 'vue';
const phoneNumber = ref('18109637662');
// 定义一个自定义过滤器
const maskPhone = (value) => {
if (!value) return '';
const start = 3;
const end = 7;
const mask = '****';
return value.substring(0, start) + mask + value.substring(end);
};
</script>