修复特殊字符造成脚本错误的bug

This commit is contained in:
q4speed 2020-05-20 12:09:38 +08:00
parent 1096b6bef0
commit 55e6ab076f
2 changed files with 16 additions and 5 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<el-form :model="request" :rules="rules" ref="request" label-width="100px"> <el-form :model="request" :rules="rules" ref="request" label-width="100px">
<el-form-item :label="$t('api_test.request.name')" prop="name"> <el-form-item :label="$t('api_test.request.name')" prop="name">
<el-input v-model="request.name" maxlength="100"/> <el-input v-model="request.name" maxlength="100" @input="valid"/>
</el-form-item> </el-form-item>
<el-form-item :label="$t('api_test.request.url')" prop="url"> <el-form-item :label="$t('api_test.request.url')" prop="url">
@ -108,6 +108,10 @@
} }
} }
return url; return url;
},
valid(value) {
value = value.replace(/[`~!@#$%^&*()_\-+=<>?:"{}|,./;'\\[\]·!¥…()—\-《》?:“”【】、;‘’,。]/g, '').replace(/\s/g, "");
this.request.name = value;
} }
}, },

View File

@ -1,12 +1,12 @@
<template> <template>
<el-form :model="scenario" :rules="rules" ref="scenario" label-width="100px"> <el-form :model="scenario" :rules="rules" ref="scenario" label-width="100px">
<el-form-item :label="$t('api_test.scenario.name')" prop="name"> <el-form-item :label="$t('api_test.scenario.name')" prop="name">
<el-input v-model="scenario.name" maxlength="100"/> <el-input v-model="scenario.name" maxlength="100" @input="valid"/>
</el-form-item> </el-form-item>
<!-- <el-form-item :label="$t('api_test.scenario.base_url')" prop="url">--> <!-- <el-form-item :label="$t('api_test.scenario.base_url')" prop="url">-->
<!-- <el-input :placeholder="$t('api_test.scenario.base_url_description')" v-model="scenario.url" maxlength="100"/>--> <!-- <el-input :placeholder="$t('api_test.scenario.base_url_description')" v-model="scenario.url" maxlength="100"/>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-tabs v-model="activeName"> <el-tabs v-model="activeName">
<el-tab-pane :label="$t('api_test.scenario.variables')" name="parameters"> <el-tab-pane :label="$t('api_test.scenario.variables')" name="parameters">
@ -43,6 +43,13 @@
] ]
} }
} }
},
methods: {
valid(value) {
value = value.replace(/[`~!@#$%^&*()\-+=<>?:"{}|,./;'\\[\]·!¥…()—\-《》?:“”【】、;‘’,。]/g, '').replace(/\s/g, "");
this.scenario.name = value;
}
} }
} }
</script> </script>