[英]How to get some of the codepoint emoji values to work
This example is working for me on Firefox 61. The output is: 本示例在Firefox 61上为我工作。输出为:
And on Google Chrome I'm having: 在Google Chrome上,我拥有:
Now, try running this code snippet: 现在,尝试运行以下代码片段:
document.querySelector('.output').textContent = String.fromCodePoint(0x1F923); console.log(String.fromCodePoint(0x1F923));
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> </head> <body> <p class='output'></p> </body> </html>
If you still getting that square, please check your browser's encoding & your default fonts. 如果仍能找到该正方形,请检查浏览器的编码和默认字体。 And check if it supports emojis, like on my Google Chrome didn't render it.
并检查它是否支持表情符号,例如在我的Google Chrome浏览器上未呈现它。
So maybe you need to use a third-party JavaScript library like Twitter's Twemoji : 因此,也许您需要使用Twitter的Twemoji之类的第三方JavaScript库:
// I got the Unicode for that emoji(1F602) from www.unicode.org/emoji/charts/full-emoji-list.html document.querySelector('.output').innerHTML = twemoji.convert.fromCodePoint('1F602');
<script src="//twemoji.maxcdn.com/2/twemoji.min.js?11.0"></script> <p class="output"></p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.