Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
5e36a8b5
Unverified
Commit
5e36a8b5
authored
Apr 17, 2021
by
啝裳
Committed by
GitHub
Apr 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: improve cropper example (#491)
parent
e1b30a50
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
18 deletions
+25
-18
index.vue
src/views/demo/comp/cropper/index.vue
+25
-18
No files found.
src/views/demo/comp/cropper/index.vue
View file @
5e36a8b5
<
template
>
<
template
>
<PageWrapper
title=
"图片裁剪示例"
contentBackground
>
<PageWrapper
title=
"图片裁剪示例"
contentBackground
>
<div
class=
"container"
>
<div
class=
"cropper-container"
>
<div
class=
"cropper-container"
>
<CropperImage
<CropperImage
ref=
"refCropper"
ref=
"refCropper"
src=
"https://fengyuanchen.github.io/cropperjs/images/picture.jpg"
src=
"https://fengyuanchen.github.io/cropperjs/images/picture.jpg"
@
cropperedInfo=
"cropperedInfo"
@
cropperedInfo=
"cropperedInfo"
style=
"width: 40%
"
style=
"width: 40vw
"
/>
/>
</div>
<a-button
type=
"primary"
@
click=
"onCropper"
>
裁剪
</a-button>
<a-button
type=
"primary"
@
click=
"onCropper"
>
裁剪
</a-button>
<img
:src=
"cropperImg"
class=
"croppered"
v-if=
"cropperImg"
/>
<img
:src=
"cropperImg"
class=
"croppered"
v-if=
"cropperImg"
/>
</div>
</div>
...
@@ -14,28 +16,26 @@
...
@@ -14,28 +16,26 @@
</PageWrapper>
</PageWrapper>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
,
ref
,
onBeforeMount
,
getCurrentInstance
}
from
'
vue
'
;
import
{
defineComponent
,
ref
,
unref
}
from
'
vue
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
import
{
PageWrapper
}
from
'
/@/components/Page
'
;
import
{
CropperImage
}
from
'
/@/components/Cropper
'
;
import
{
CropperImage
}
from
'
/@/components/Cropper
'
;
import
img
from
'
/@/assets/images/header.jpg
'
;
import
img
from
'
/@/assets/images/header.jpg
'
;
import
{
templateRef
}
from
'
@vueuse/core
'
;
export
default
defineComponent
({
export
default
defineComponent
({
components
:
{
components
:
{
PageWrapper
,
PageWrapper
,
CropperImage
,
CropperImage
,
},
},
setup
()
{
setup
()
{
let
vm
:
any
;
let
info
=
ref
(
''
);
let
info
=
ref
(
''
);
let
cropperImg
=
ref
(
''
);
let
cropperImg
=
ref
(
''
);
const
refCropper
=
templateRef
<
HTMLElement
|
null
>
(
'
refCropper
'
,
null
);
const
onCropper
=
():
void
=>
{
const
onCropper
=
():
void
=>
{
vm
.
refs
.
refCropper
.
croppered
();
unref
(
refCropper
)
.
croppered
();
};
};
onBeforeMount
(()
=>
{
vm
=
getCurrentInstance
();
});
function
cropperedInfo
({
imgBase64
,
imgInfo
})
{
function
cropperedInfo
({
imgBase64
,
imgInfo
})
{
info
.
value
=
imgInfo
;
info
.
value
=
imgInfo
;
cropperImg
.
value
=
imgBase64
;
cropperImg
.
value
=
imgBase64
;
...
@@ -53,14 +53,21 @@
...
@@ -53,14 +53,21 @@
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
.c
ropper-c
ontainer
{
.container
{
display
:
flex
;
display
:
flex
;
justify-content
:
space-around
;
width
:
100vw
;
align-items
:
center
;
align-items
:
center
;
}
}
.cropper-container
{
width
:
40vw
;
}
.croppered
{
.croppered
{
width
:
50%
;
height
:
360px
;
height
:
100%
;
}
p
{
margin
:
10px
;
}
}
</
style
>
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment