vue 身份证号码 中间用*代替

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Vue filters</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="item in ID">{{item | hideMiddle}}</li>
        </ul>
    </div>
    <script type="text/javascript">
        new Vue({
            el: '#app',
            data: {
                ID: [
                "1234567897897","5648754542132"]
            },
            methods: {            
            },
            filters: {
                hideMiddle(val) {
                    return `${val.substring(0,3)}****${val.substring(val.length-3)}`
                }
            }
        })
    </script>
</body>
</html>

 

上一篇:课程主页之课程接口


下一篇:Vue中过滤器filters的实现,从青铜到王者