jsÖÐÔõôÌí¼ÓÐÄÇé·ûºÅ
ÔÚ javascript ÖÐÌí¼ÓÐÄÇé·ûºÅÓÐÒÔÏÂÒªÁ죺ʹÓà string.fromcodepoint() ½¨Éè×Ö·û´®Ê¹Óà html ʵÌåÌåÏÖÐÄÇé·ûºÅʹÓà unicode ÌÓÒÝÐòÁÐÌåÏÖ×Ö·ûʹרÐÄÇé·ûºÅ¿â½¨Éè×Ô½ç˵ÐÄÇé·ûºÅ
ÔõÑùÔÚ JavaScript ÖÐÌí¼ÓÐÄÇé·ûºÅ
ÔÚ JavaScript ÖÐÌí¼ÓÐÄÇé·ûºÅµÄÒªÁìÈçÏ£º
1. ʹÓà String.fromCodePoint()
String.fromCodePoint() ÒªÁìÔÊÐíÄú´Ó Unicode ×Ö·ûµã½¨Éè×Ö·û´®£¬°üÀ¨ÐÄÇé·ûºÅ¡£ÀýÈ磺
const emoji = String.fromCodePoint(0x1F600); // ? console.log(emoji); // ?
µÇ¼ºó¸´ÖÆ
2. ʹÓà HTML ʵÌå
Äú¿ÉÒÔʹÓà HTML ʵÌåÀ´ÌåÏÖÐÄÇé·ûºÅ¡£HTML ʵÌåÊÇÌØÊâ×Ö·û£¬¿ÉÒÔת»»ÎªÏìÓ¦µÄ×Ö·û¡£ÀýÈ磺
const emoji = "& #128512;"; // ? console.log(emoji); // ?
µÇ¼ºó¸´ÖÆ
3. ʹÓà Unicode ÌÓÒÝÐòÁÐ
Unicode ÌÓÒÝÐòÁÐÊÇʹÓ÷´Ð±¸Ü (`) ºÍÊ®Áù½øÖÆ´úÂëÌåÏÖ×Ö·ûµÄÒªÁì¡£Äú¿ÉÒÔÔÚ JavaScript ÖÐʹÓÃËüÃÇÀ´ÌåÏÖÐÄÇé·ûºÅ¡£ÀýÈ磺
const emoji = "\uD83D\uDE00"; // ? console.log(emoji); // ?
µÇ¼ºó¸´ÖÆ
4. ʹרÐÄÇé·ûºÅ¿â
ÓÐÐí¶àÐÄÇé·ûºÅ¿â¿É¹©ÓÃÓÚ JavaScript¡£ËüÃÇÌṩÁËÒ»¸ö¿ÉÒÔÇáËÉ»á¼ûºÍʹÓõÄÐÄÇé·ûºÅÜöÝÍ¡£Ò»Ð©Ê¢ÐеĿâ°üÀ¨£º
[emojione](https://emojione.com/)
[Twemoji](https://github.com/twitter/twemoji)
[JoyPixels](https://www.joypixels.com/)
5. ½¨Éè×Ô½ç˵ÐÄÇé·ûºÅ
Äú»¹¿ÉÒÔ½¨Éè×Ô¼ºµÄ×Ô½ç˵ÐÄÇé·ûºÅ¡£Îª´Ë£¬ÄúÐèҪʹÓÃͼÏñ±à¼Èí¼þ½¨ÉèÒ»¸öͼÏñ£¬È»ºó½«Æäת»»Îª WebP »ò PNG µÈÃûÌá£È»ºó£¬Äú¿ÉÒÔʹÓà Image ¹¤¾ß½«ÆäÌí¼Óµ½ÄúµÄ JavaScript ´úÂëÖС£
ÒÔÉϾÍÊÇjsÖÐÔõôÌí¼ÓÐÄÇé·ûºÅµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡