mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-02-22 04:30:33 +09:00
15 lines
384 B
JavaScript
15 lines
384 B
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = [ "image", "input" ]
|
|
|
|
previewImage() {
|
|
const file = this.inputTarget.files[0]
|
|
|
|
if (file) {
|
|
this.imageTarget.src = URL.createObjectURL(this.inputTarget.files[0]);
|
|
this.imageTarget.onload = () => { URL.revokeObjectURL(this.imageTarget.src) }
|
|
}
|
|
}
|
|
}
|