|
勇哥 发表于 2015-7-22 09:01
那我怎么根据[微笑] 得到这个图片呢
// 表情转换
function transText(text, imgWidth, imgHeight){
var imgWidth = imgWidth || 30;
var imgHeight = imgHeight || 30;
var regx = /\[(.*?)\]/gm;
var textTransed = text.replace(regx,function(match){
var imgSrc = emotionData[match];
if(!imgSrc){
//说明不对应任何表情,直接返回
return match;
}
var img = "<img src="+imgSrc+" width="+imgWidth+" height="+imgHeight+">";
return img;
});
return textTransed;
}
我用了这个代码 提示我emotionData is not defined |
|