Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
html-shot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
劳工
html-shot
Commits
8e701459
Commit
8e701459
authored
Oct 08, 2021
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support mask
parent
47dface0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
test.html
test.html
+1
-1
test.js
test.js
+6
-2
No files found.
test.html
View file @
8e701459
...
...
@@ -15,7 +15,6 @@
.poster
{
position
:
relative
;
background-color
:
orange
;
border-radius
:
2.00rem
;
border
:
0.1rem
solid
blue
;
width
:
5.20rem
;
height
:
4.40rem
;
...
...
@@ -84,5 +83,6 @@
<script
src=
"test.js"
type=
"module"
></script>
<button
id=
"button"
>
截图
</button>
<div
id=
"results"
></div>
</body>
</html>
test.js
View file @
8e701459
...
...
@@ -4,12 +4,16 @@
import
{
htmlShot
}
from
"./dist/index.js"
;
const
scale
=
window
[
'devicePixelRatio'
]
||
1
async
function
shot
()
{
const
result
=
await
htmlShot
(
document
.
getElementById
(
'poster'
),
{
type
:
'png'
});
let
img
=
new
Image
();
img
.
src
=
result
;
img
.
style
.
width
=
'365px'
document
.
body
.
appendChild
(
img
);
img
.
style
.
zoom
=
`
${
1
/
scale
}
`
const
container
=
document
.
getElementById
(
'results'
)
container
.
appendChild
(
img
);
}
document
.
getElementById
(
'button'
).
onclick
=
shot
;
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