primevue-mirror/apps/showcase/doc/fileupload/BasicDoc.vue

79 lines
2.4 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>FileUpload basic <i>mode</i> provides a simpler UI as an alternative to default advanced mode.</p>
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-col gap-6 items-center justify-center">
2024-05-09 14:46:36 +00:00
<FileUpload ref="fileupload" mode="basic" name="demo[]" url="/api/upload" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
<Button label="Upload" @click="upload" severity="secondary" />
2023-02-28 08:29:30 +00:00
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
code: {
2023-09-22 12:54:14 +00:00
basic: `
2024-05-09 14:46:36 +00:00
<FileUpload ref="fileupload" mode="basic" name="demo[]" url="/api/upload" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
<Button label="Upload" @click="upload" severity="secondary" />
2023-10-15 09:38:39 +00:00
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-col gap-6 items-center justify-center">
2023-02-28 08:29:30 +00:00
<Toast />
2024-05-09 14:46:36 +00:00
<FileUpload ref="fileupload" mode="basic" name="demo[]" url="/api/upload" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
<Button label="Upload" @click="upload" severity="secondary" />
2023-02-28 08:29:30 +00:00
</div>
</template>
<script>
export default {
methods: {
2024-05-09 14:46:36 +00:00
upload() {
2024-05-10 06:38:54 +00:00
this.$refs.fileupload.upload();
2024-05-09 14:46:36 +00:00
},
2023-02-28 08:29:30 +00:00
onUpload() {
this.$toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
}
}
};
2023-10-15 09:38:39 +00:00
<\/script>
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-col gap-6 items-center justify-center">
2023-02-28 08:29:30 +00:00
<Toast />
2024-05-09 14:46:36 +00:00
<FileUpload ref="fileupload" mode="basic" name="demo[]" url="/api/upload" accept="image/*" :maxFileSize="1000000" @upload="onUpload" />
<Button label="Upload" @click="upload" severity="secondary" />
2023-02-28 08:29:30 +00:00
</div>
</template>
<script setup>
import { useToast } from "primevue/usetoast";
const toast = useToast();
2024-05-09 14:46:36 +00:00
const fileupload = ref();
const upload = () => {
2024-05-10 06:38:54 +00:00
fileupload.value.upload();
2024-05-09 14:46:36 +00:00
};
2023-02-28 08:29:30 +00:00
const onUpload = () => {
toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
};
2023-10-15 09:38:39 +00:00
<\/script>
`
2023-02-28 08:29:30 +00:00
}
};
},
methods: {
2024-05-09 14:46:36 +00:00
upload() {
2024-05-10 06:38:54 +00:00
this.$refs.fileupload.upload();
2024-05-09 14:46:36 +00:00
},
2023-02-28 08:29:30 +00:00
onUpload() {
this.$toast.add({ severity: 'info', summary: 'Success', detail: 'File Uploaded', life: 3000 });
}
}
};
</script>