From b5a6b99f7afefadabc5050304b90e4a6ab3d64e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E4=B8=BD=E5=90=9B?= <664953382@qq.com> Date: Mon, 11 Oct 2021 14:08:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=87=E6=BB=A4=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E5=AD=97=E7=AC=A6=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 2 ++ src/utils/index.js | 10 +++++++++- src/views/policy/library/index.vue | 3 +++ src/views/policy/tag/index.vue | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 313cd44..7999f8b 100644 --- a/src/main.js +++ b/src/main.js @@ -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' }); diff --git a/src/utils/index.js b/src/utils/index.js index 918580f..ac86304 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -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 +} diff --git a/src/views/policy/library/index.vue b/src/views/policy/library/index.vue index 12f9808..88f9e0e 100644 --- a/src/views/policy/library/index.vue +++ b/src/views/policy/library/index.vue @@ -17,7 +17,10 @@ v-model="queryParams.title" placeholder="请输入" clearable + @input="e => queryParams.title = stripscript(e)" /> + + - + - + {{item.name}}