大家好,我有以下代码输入:
<v-file-input
class="mx-6"
show-size
accept=".xlsx"
label="File input"
@change="selectFile"
></v-file-input>如何使它只接受特定的names.xlsx?就像它会接受包含特定单词的xlsx文件一样。
Example:
name-george.xlsx true
name-anna.xlsx false
george-surname.xlsx true我希望它在xlsx文件名中包含george word
发布于 2022-12-01 14:09:45
使用验证规则。下面是一个让你开始的例子
https://codepen.io/radvic/pen/XWYxKpQ
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
rules: [
v => {
for(index in v){
const fileName = v[index].name;
if(fileName.match(/george(.*)\.xlsx/g) === null){
return 'The file name "'+fileName+'" is wrong';
}
}
return true;
},
],
}),
})<script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.0.18/dist/vuetify.min.js"></script>
<div id="app">
<v-app id="inspire">
<v-file-input multiple :rules="rules" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"></v-file-input>
</v-app>
</div>
https://stackoverflow.com/questions/74642626
复制相似问题