vue显示微信用户名称中enjoin表情

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

转换代码:

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

computed下的代码:

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

 computed: {

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

猜你喜欢

转载自www.cnblogs.com/wangyang0210/p/10323211.html