<template>
<view>
<view class="flex a-c" style="height: 100rpx;width: 100%; ">
<view class="" style="height: 50rpx " >
{{xphonenumbool?allphonenum:isunum}}
</view>
<view class="aj-c" @click="select" style="width: 100rpx;height: 50rpx ">
<!-- 方法很多
<image v-if="!xphonenumbool" src="../../static/noseay.png" ></image>
<image v-if="xphonenumbool" src="../../static/yeseay.png" ></image>
-->
<image :src="`../../static/${!xphonenumbool?'noseay':'yeseay'}.png`" >
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
allphonenum: '18338088912',
xphonenum: '',
xphonenumbool: false,
}
},
methods: {
select() {
this.xphonenumbool = !this.xphonenumbool;
},
},
computed: {
isunum: function() {
const newarr = this.allphonenum.split('');
newarr.forEach((item, index, arr) => {
if (index > 2 && index < 7) {
arr[index] = '*'
}
})
return newarr.join('');
}
}
}
</script>
<style>
image {
width: 100%;
height: 100%;
}
</style>