美文网首页
vue去除特殊字符Mixin

vue去除特殊字符Mixin

作者: 爱忽悠的唐唐在晃悠 | 来源:发表于2018-06-01 17:21 被阅读22次
    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

          本文链接:https://www.haomeiwen.com/subject/jwuksftx.html