Vue用の最速の絵文字ピッカー「vue-twemoji-picker」
by kabanoki
HTML
<script src="https://cdn.jsdelivr.net/npm/@kevinfaguiar/[email protected]/dist/vue-twemoji-picker.umd.min.js"></script>
<div id="app">
<twemoji-textarea
:emoji-data="emojiDataAll"
:emoji-groups="emojiGroups"
:maxlength="100"
@enter-key="onEnterKey">
</twemoji-textarea>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@kevinfaguiar/[email protected]/dist/vue-twemoji-picker.umd.min.js"></script>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
Vue
document.addEventListener("DOMContentLoaded", function() {
(async function(){
const fetchedDataAllResponse = await fetch(
"https://unpkg.com/@kevinfaguiar/[email protected]/emoji-data/en/emoji-all-groups.json"
);
window.EmojiDataAll = await fetchedDataAllResponse.json();
const fetchedGroupsResponse = await fetch(
"https://unpkg.com/@kevinfaguiar/[email protected]/emoji-data/emoji-groups.json"
);
window.EmojiGroups = await fetchedGroupsResponse.json();
const TwemojiTextarea = window['VueTwemojiPicker'].TwemojiTextarea;
new Vue({
data: {
EmojiAllData: window.EmojiDataAll,
EmojiGroups: window.EmojiGroups
},
components: {
'twemoji-textarea': TwemojiTextarea
},
computed: {
emojiDataAll:function() {
return this.EmojiAllData;
},
emojiGroups:function() {
return this.EmojiGroups;
}
},
methods: {
onEnterKey: function(msg){
console.log(msg);
}
}
}).$mount('#app');
})();
});