在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue中使用iview的table表格讓顯示的數(shù)據(jù)部分顯示為星號?158****

vue中使用iview的table表格讓顯示的數(shù)據(jù)部分顯示為星號?158*****496怎么設(shè)置

表格數(shù)據(jù) 脫敏處理
15812345789
顯示成如下
158*496

回答
編輯回答
陌璃

使用Vue的過濾器(filters)
我給你直接寫了一個例子,你直接復(fù)制粘貼到一個HTML文件中打開就能看到效果,希望能幫助到你:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>例子</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>

<body>
    <div id="app">
        {{ message | protect }}
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                message: '15761695277'
            },
            filters: {
                protect: function(value) {
                    if (!value) {
                        return ''
                    }
                    //對字符串進(jìn)行截取
                    //substr(0, 3)表示從0開始取三位
                    //substr(-3)表示從后面數(shù)第三位開始取到最后
                    // *號隨便加 多長都行
                    return value.substr(0, 3) + "*" + value.substr(-3);
                }
            }
        })
    </script>
</body>

</html>
2017年7月30日 08:01
編輯回答
法克魷

讓后臺處理。脫敏在前端就是笑話。

update:
雖然反對前端處理,但是碰到SB的老大,不得不服??梢允褂谜齽t替換:

// 13012345123 -> 130*****123
replacePhone: function (str) {
  if(!str){
    return ''
  }
  return str.replace(/(\d{3})\d{5}(\d{3})/, '$1****$2');
}
2018年1月26日 12:01
編輯回答
膽怯

這種問題還是交給后臺來做。前端做的都是偽加密。如果非要做的話就是用正則表達(dá)式替換了。

2018年9月1日 15:22