vue去除特殊字符Mixin

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
        }
    }
}

 

你可能感兴趣的:(vue去除特殊字符Mixin)