Skip to content

Commit 1de630c

Browse files
committed
refactor: 按照 code review 建议做些小修改
1 parent b741c74 commit 1de630c

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/packages/uploader/demos/h5/demo15.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Uploader } from '@nutui/nutui-react'
44
const Demo15 = () => {
55
return (
66
<>
7-
<Uploader enablePasteUpload />
7+
<Uploader enablePasteUpload uploadLabel="点击上传或粘贴图片" />
88
</>
99
)
1010
}

src/packages/uploader/doc.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ app.post('/upload', upload.single('file'), (req, res) => {
139139

140140
### 浏览器中粘贴图片上传
141141

142+
在浏览器中可以通过 Ctrl+V(Mac 上是 Cmd+V) 或右键粘贴图片进行上传。
143+
142144
:::demo
143145

144146
<CodeBlock src='h5/demo15.tsx'></CodeBlock>

src/packages/uploader/uploader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ const InternalUploader: ForwardRefRenderFunction<
396396

397397
const files: File[] = []
398398

399-
if (clipboardData.items && clipboardData.items.length) {
399+
if (clipboardData?.items && clipboardData.items.length) {
400400
for (let i = 0; i < clipboardData.items.length; i++) {
401401
const item = clipboardData.items[i]
402402
if (item.kind === 'file' && item.type.startsWith('image/')) {
@@ -406,7 +406,7 @@ const InternalUploader: ForwardRefRenderFunction<
406406
}
407407
}
408408
}
409-
} else if (clipboardData.files && clipboardData.files.length) {
409+
} else if (clipboardData?.files && clipboardData.files.length) {
410410
for (let i = 0; i < clipboardData.files.length; i++) {
411411
const file = clipboardData.files[i]
412412
if (file.type.startsWith('image/')) {

0 commit comments

Comments
 (0)