generated from Flycro/laravel-nuxt
fix: Preview for local Files #4
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -118,6 +118,10 @@ async function onSubmit(event: FormSubmitEvent<any>) {
|
||||
function isFile(value: any): value is File {
|
||||
return value instanceof File
|
||||
}
|
||||
|
||||
function getFileUrl(file: File) {
|
||||
return URL.createObjectURL(file)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -150,7 +154,7 @@ function isFile(value: any): value is File {
|
||||
</UFormGroup>
|
||||
<img v-if="state.cover_image && typeof state.cover_image === 'string'" :src="$storage(state.cover_image)" alt="Cover" class="size-1/3 content-center rounded-lg">
|
||||
<ClientOnly>
|
||||
<img v-if="state.cover_image && isFile(state.cover_image)" :src="URL.createObjectURL(state.cover_image)" alt="Cover" class="size-1/3 content-center rounded-lg">
|
||||
<img v-if="state.cover_image && isFile(state.cover_image)" :src="getFileUrl(state.cover_image)" alt="Cover" class="size-1/3 content-center rounded-lg">
|
||||
</ClientOnly>>
|
||||
<UFormGroup label="Cover" name="cover_image">
|
||||
<UInput type="file" @change="handleCoverImageInput" />
|
||||
|
||||
Reference in New Issue
Block a user