11<!-- eslint-disable no-console -->
22<script lang="ts" setup>
3- import { onMounted , ref , useTemplateRef } from ' vue'
3+ import { onMounted , ref , useTemplateRef , h } from ' vue'
44import { ModernCropper } from ' ~/index'
55import { isDark , toggleDarkmode } from ' @/composables/useDarkmode'
66
@@ -69,10 +69,16 @@ onMounted(async () => {
6969 cropper: { constructOptions: undefined },
7070 image: { attributes: { class: 'blur' } },
7171 canvas: { attributes: { background: false } },
72- selection: { attributes: undefined },
72+ selection: { attributes: { id: 'cropper-selection-86' } },
7373 selections: { attributes: undefined },
7474 }"
7575/>
76+
77+ // To creates a 'cropper-viewer' component
78+ <component
79+ v-if="cropper?.cropperMounted"
80+ :is="h('cropper-viewer', { selection: '#cropper-selection-86' })"
81+ />
7682...
7783`
7884 </script >
@@ -139,9 +145,12 @@ onMounted(async () => {
139145 <Highlight :autodetect =" false" language =" javascript" :code =" demoCode0" />
140146 </main >
141147
142- <div class =" my-2 text-primary" >
148+ <div class =" my-2 text-primary flex flex-col gap-4 " >
143149 Check out cropperjs's document: <a href =" https://fengyuanchen.github.io/cropperjs/" class =" text-#3399ff" >https://fengyuanchen.github.io/cropperjs/</a >
144- <div class =" flex items-center justify-center" >
150+
151+ <hr >
152+
153+ <div class =" flex items-center justify-center gap-10" >
145154 <ModernCropper
146155 ref =" cropper"
147156 class =" h-40 w-80"
@@ -150,10 +159,17 @@ onMounted(async () => {
150159 cropper: { constructOptions: undefined },
151160 image: { attributes: { class: 'blur' } },
152161 canvas: { attributes: { background: false } },
153- selection: { attributes: undefined },
162+ selection: { attributes: { id: 'cropper-selection-69' } },
154163 selections: { attributes: undefined },
155164 }"
156165 />
166+
167+ <div class =" w-80 h-40 overflow-hidden" >
168+ <component
169+ v-if =" cropper?.cropperMounted"
170+ :is =" h('cropper-viewer', { selection: '#cropper-selection-69' })"
171+ />
172+ </div >
157173 </div >
158174 </div >
159175
0 commit comments