app直播源代码,vue 自定义指令过滤特殊字符
/**
* @tags input 只可以輸入数字、字母、汉字
* @example v-emoji
*/
export default (app) => {
app.directive('emoji', {
mounted(el, binding) {
// console.log(binding)
el.oninput = (e) => {
if (e.target.value != '') {
const pattern = new RegExp(/[^a-zA-Z0-9_\u4e00-\u9fa5]+$/gi);
e.target.value = e.target.value.replace(pattern, '');
}
// el.blur();
el.focus();
};
// el.onchange = (e) => {
// e.target.value = e.target.value.trim();
// };
el.onblur = (e) => {
// console.log(e.target.value)
e.target.value = e.target.value.trim();
};
el.onfocus = (e) => {
// console.log(e.target.value)
e.target.value = e.target.value.trim();
};
},
});
};
使用
import { createApp } from 'vue';
import emoji from '/@/emoji';
const app = createApp({});
emoji(app);
以上就是 app直播源代码,vue 自定义指令过滤特殊字符,更多内容欢迎关注之后的文章
标签:el,vue,target,自定义,app,value,源代码,emoji From: https://www.cnblogs.com/yunbaomengnan/p/17024662.html