[每天进步一点点~] uni-app 隐藏手机号中间四位数、邮箱号码中间部分隐藏

1. 隐藏手机号中间四位

效果图:

代码:

<template>
    <view class="">
        <view class="">我们向{
   
   {tel}}发送了验证码</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                tel: '15807716888',
            }
        },
        onShow() {
            this.phoneNumShow()
        },
        methods: {
            //隐藏手机号
            phoneNumShow () {
                let that = this;
                let number = this.tel; //获取到手机号码字段
                console.log('手机号', this.tel)
                let mphone = number.substring(0, 3) + '****' + number.substring(7);
                that.tel = mphone
            },
        }
    }
</script>

<style lang="scss" scoped>

</style>

2. 邮箱号中间部分隐藏

效果图:

代码:

<template>
    <view class="">
        <view class="">我们向{
   
   { email }}发送了验证邮件</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                email: '[email protected]',
            }
        },
        onShow() {
            this.settingemail()
        },
        methods: {
            //隐藏邮箱
            settingemail() {
                let that = this;
                let email = this.email; //获取到邮箱字段
                console.log('邮箱', this.email)
                let memail = email.substring(0, 3) + '****' + email.substring(9);
                that.email = memail
            },
        }
    }
</script>

<style lang="scss" scoped>
</style>

猜你喜欢

转载自blog.csdn.net/DarlingYL/article/details/114526884