[Vuejs]-Replace a string in textarea with emoji | VueJS

0πŸ‘

what about something like this:

watch: {
  message: function() {
    const replacements = {
      ":-)": "πŸ™‚",
      ":-(": "😞",
      ";-)": "πŸ˜‰",
      ":-|": "😐",
      ":'-(": "😒",
      ":-*": "😘",
      "*.*": "😍",
      ";-P": "😜",
      "8-)": "😎",
      ":-D": "πŸ˜„",
      "=-D": "πŸ˜ƒ"
    }
    Object.keys(replacements).forEach(k => {
      this.message = this.message.replace(k, replacements[k])
    })
  }
}

Leave a comment