利用vue.js 實現(xiàn)輸入框輸入值自動過濾特殊字符的功能?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。
verifyInput(v){ let _this=this; let punctuation = /[`~!@#$%^&*_\-=<>?:"{}|.\/;'\\[\]·~!@#¥%……&——\-={}|《》?:“”【】、;‘'。、]/im; let arr=v.split('') let str='' arr.map(i=>{ if(!punctuation.test(i)){ str+=i } }) str=str.replace(/(/g,'(') str=str.replace(/)/g,')') str=str.replace(/,/g,',') this.$nextTick(j=>{ this.relatedWords=str }) },