添加过滤特殊字符方法

This commit is contained in:
熊丽君
2021-10-11 14:08:07 +08:00
parent 8816f05549
commit b5a6b99f7a
4 changed files with 16 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import {
handleTree
} from '@/utils/ruoyi';
import { formatRichText } from '@/utils/editor';
import { stripscript } from '@/utils';
import Pagination from '@/components/Pagination';
//自定义表格工具扩展
import RightToolbar from '@/components/RightToolbar';
@ -43,6 +44,7 @@ Vue.prototype.selectDictLabels = selectDictLabels;
Vue.prototype.download = download;
Vue.prototype.handleTree = handleTree;
Vue.prototype.formatRichText = formatRichText;
Vue.prototype.stripscript = stripscript;
Vue.prototype.msgSuccess = function(msg) {
this.$message({ showClose: true, message: msg, type: 'success' });

View File

@ -387,4 +387,12 @@ export function camelCase(str) {
export function isNumberStr(str) {
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
}
export function stripscript(value) {
let pattern = new RegExp("[`~!@#$%^&*()=|{}':;',\\[\\].<>/?~@#¥……&*()——|{}【】‘;:”“'。,、?]")
let str = "";
for (let i = 0; i < value.length; i++) {
str = str+value.substr(i, 1).replace(pattern, '');
}
return str
}

View File

@ -17,7 +17,10 @@
v-model="queryParams.title"
placeholder="请输入"
clearable
@input="e => queryParams.title = stripscript(e)"
/>
<!-- onkeyup="value=value.replace(/[\W]/g,'')" -->
<!-- onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" -->
</el-form-item>
<el-form-item label="产出">
<el-select

View File

@ -55,9 +55,9 @@
<el-dialog :title="str" :visible.sync="addDialog" width="500px">
<el-form :model="form" ref="form" :rules="rules" @submit.native.prevent>
<el-form-item label="名称" prop="name" label-width="80px">
<el-input v-model="form.name"></el-input>
<el-input v-model="form.name" maxlength="20" show-word-limit></el-input>
</el-form-item>
<el-form-item label="已添加" label-width="80px">
<el-form-item label="已添加" label-width="80px" v-if="str=='添加标签'">
<el-tag style="margin-right:10px" v-for="item in tagList" :key="item.id">{{item.name}}</el-tag>
</el-form-item>
</el-form>