1、应用系统字符(%¥……&,防SQL注入)输入框的特殊字符过滤:
在main.js 引入以下代码,即可全局使用。
Vue.prototype.validSe = function(value) { value = value.replace(/[`~*~!@#$%^&*()_-+=<>?:"{}|,./;'\[]·~!@#¥%……&*()——-+={}|《》?:“”【】、;‘’,。、]/g, '').replace( /s/g, ""); return value; };
在需要用到的地方:
<el-input :value="searchVal.Title" @input="e => (searchVal.Title = validSe(e))" placeholder="请输入标题">
</el-input>
需注意的是,:value="" 内的东西 需在data里定义好