[A little progress every day~] uni-app hides the middle four digits of the mobile phone number and the middle part of the mailbox number

1. Hide the middle four digits of the phone number

Renderings:

code:

<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. The middle part of the mailbox number is hidden

Renderings:

code:

<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>

Guess you like

Origin blog.csdn.net/DarlingYL/article/details/114526884