简体   繁体   English

如何在Angular应用中将表情符号映射到数值?

[英]How do I map emojis to numerical values in my Angular app?

I need a functionality in my angular 6 app to implement that different emojis have different numerical values. 我在我的angular 6应用程序中需要一个功能来实现不同的表情符号具有不同的数值。

For example, if a post is created by a user which has 3 sad and 2 smiley emojis then the resulting values will be 2 x 3 = 6 and 4 x 2 = 8 . 例如,如果帖子是由具有3个悲伤表情符号和2个笑脸表情符号的用户创建的,则结果值将为2 x 3 = 64 x 2 = 8

How do I map these emojis to numerical values so that I can perform calculations on these values? 如何将这些表情符号映射到数字值,以便可以对这些值执行计算?

Just make an object in JS that translates between the emoji code and value like: 只需在JS中创建一个可在表情符号代码和值之间进行转换的对象,例如:

    const emojiValues = { “&#x1F354”: 1 }
    let value = emojiValues[“&#x1F354”] // fetch if back

More detailed discussion on how to use emojis in HTML is here: https://www.kirupa.com/html5/emoji.htm 有关如何在HTML中使用表情符号的更多详细讨论,请参见: https//www.kirupa.com/html5/emoji.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM