vue去除特殊字符Mixin
export const trim = {methods: {trim(value) {/**去除首尾空白 */return value.replace(/(^\s*)|(\s*$)/g, "");},}}export const validateSpecialCharacter = ...
·
export const trim = {
methods: {
trim(value) {
/**去除首尾空白 */
return value.replace(/(^\s*)|(\s*$)/g, "");
},
}
}
export const validateSpecialCharacter = {
methods: {
/**验证特殊字符和空格 */
inputformat (event,value) {
if (this.composing) {
return
}
let inputValue = event.target.value
event.target.value = event.target.value.replace(/[^\a-\z\A-\Z0-9_\u4E00-\u9FA5]/g, "")
let filterValue = inputValue.replace(/[^\a-\z\A-\Z0-9_\u4E00-\u9FA5]/g, "")
util.setDeepValue(value,filterValue)(this);
event.target.dispatchEvent(new Event('input'))
},
compositionstart (data) {
this.composing = true
},
compositionend ($event) {
this.composing = false
}
}
}
更多推荐
已为社区贡献8条内容
所有评论(0)