mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
style
This commit is contained in:
parent
b653859f61
commit
4346bf8c05
@ -23,7 +23,8 @@ module.exports = {
|
||||
document: false,
|
||||
navigator: false,
|
||||
window: false,
|
||||
require: true
|
||||
require: true,
|
||||
FileReader: true
|
||||
},
|
||||
|
||||
rules: {
|
||||
|
@ -21,43 +21,36 @@
|
||||
resultType: {
|
||||
type: String,
|
||||
default: 'dataUrl',
|
||||
validator (value) {
|
||||
return value == 'dataUrl' || value == 'text'
|
||||
validator(value) {
|
||||
return value === 'dataUrl' || value === 'text';
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onValueChange (event) {
|
||||
|
||||
onValueChange(event) {
|
||||
if (this.disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
var files = event.target.files;
|
||||
var file = files[0];
|
||||
if (!file) return;
|
||||
|
||||
if (this.beforeRead && ! this.beforeRead(file)) return;
|
||||
|
||||
if (this.beforeRead && !this.beforeRead(file)) return;
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = (e) => {
|
||||
this.$emit('file-readed',
|
||||
{
|
||||
name:file.name,
|
||||
type:file.type,
|
||||
size:file.size,
|
||||
content:e.target.result
|
||||
name: file.name,
|
||||
type: file.type,
|
||||
size: file.size,
|
||||
content: e.target.result
|
||||
});
|
||||
this.$refs.input.value = '';
|
||||
};
|
||||
|
||||
if (this.resultType == 'dataUrl') {
|
||||
if (this.resultType === 'dataUrl') {
|
||||
reader.readAsDataURL(file);
|
||||
} else if (this.resultType == 'text') {
|
||||
} else if (this.resultType === 'text') {
|
||||
reader.readAsText(file);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user