Merge pull request #4509 from caibirdme/feature-translate-into-Chinese
tanslate file-object.md
This commit is contained in:
commit
57f322a818
1 changed files with 29 additions and 0 deletions
29
docs-translations/zh-CN/api/file-object.md
Normal file
29
docs-translations/zh-CN/api/file-object.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
# `File`对象
|
||||
|
||||
为了让用户能够通过HTML5的file API直接操作本地文件,DOM的File接口提供了对本地文件的抽象。Electron在File接口中增加了一个path属性,它是文件在系统中的真实路径。
|
||||
|
||||
---
|
||||
|
||||
获取拖动到APP中文件的真实路径的例子:
|
||||
|
||||
```
|
||||
<div id="holder">
|
||||
Drag your file here
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var holder = document.getElementById('holder');
|
||||
holder.ondragover = function () {
|
||||
return false;
|
||||
};
|
||||
holder.ondragleave = holder.ondragend = function () {
|
||||
return false;
|
||||
};
|
||||
holder.ondrop = function (e) {
|
||||
e.preventDefault();
|
||||
var file = e.dataTransfer.files[0];
|
||||
console.log('File you dragged here is', file.path);
|
||||
return false;
|
||||
};
|
||||
</script>
|
||||
```
|
Loading…
Reference in a new issue