vue emoji表情符号替换
<input v-model="value" @input="setValue($event.target)" placeholder="edit me">
export default {
name: 'MainContent',
data () {
return {
value:''
}
},
methods: {
setValue (target) {
let val = target.value;
let pattern = /[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/ig
if(pattern.test(val)){
val = val.replace(pattern, '');
console.info("匹配到了表情");
}
this.value = val;
}
}
}