Answer the question
In order to leave comments, you need to log in
Why can't the text in the element be updated later when using the directive?
I have a directive with which you can make a normal display of emoji (from a simple emoji, an img is made with a picture of this emoji).
Here is the directive itself:
Vue.directive('emoji', (el) => {
el.innerHTML = emoji(el.innerHTML);
});
<div class="conversation_name" v-emoji>{{ chatName }}</div>
Answer the question
In order to leave comments, you need to log in
Vue.directive('emoji', (el, binding) => el.innerHTML = emoji(binding.value));
<div class="conversation_name" v-emoji="chatName"></div>
Make a regular component instead of a directive, it fits more in its essence here.
export default {
name: 'EmojiImage',
props: {
emoji: 'String'
},
computed: {
image() {
return ''; \\ Здесь сформируйте url картинки, это так же позволит использовать кэш, загружать их асинхронно
}
}
}
<template>
<span class="emoji-image">
<img :src="image" :alt="emoji" />
</span>
</template>
<EmojiImage :emoji="emoji" />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question