首页 > 技术文章 > Vue——显示微信用户名称中enjoin表情

wangyang0210 2019-01-26 13:19 原文

后端做了处理转为了Unicode编码存入数据库,但是取出来没做处理,所以前端就做下简单的处理

转换代码:

function decodeUnicode(str) {
    str = str.replace(/\\/g, "%");
    return unescape(str);
};

computed下的代码:

因为要针对数组中的某一元素进行排序,所以先排序,然后再次对这个数组中的用户名称进行转换

 computed: {
        draw_user: function() {
      for(var i=0;i<this.code_redult.length;i++){
                 this.code_result[i]['username'] = decodeUnicode(this.code_result[i].username);
            }
            return this.code_result; 
        }
    },

 

推荐阅读