試試這個:
this.$.myFile.inputElement.inputElement.files[0]
紙輸入有屬性inputElement獲得其鐵輸入。而這個元素反過來在它的影子根目錄中具有文件屬性的本地輸入。
你的輸入可以是:
<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="../bower_components/paper-input/paper-input.html">
<dom-module id="my-paper-input-file">
<template>
<style>
:host {
display: block;
padding: 10px;
}
</style>
<paper-input type="file" id="myFile" on-change="_handleFiles"></paper-input>
</template>
<script>
class MyPaperInputFile extends Polymer.Element {
static get is() { return 'my-paper-input-file'; }
static properties() {
files: Object
}
_handleFiles(e) {
this.files = this.$.myFile.inputElement.inputElement.files;
//SAME: this.files = e.target.inputElement.inputElement.files;
}
}
window.customElements.define(MyPaperInputFile.is, MyPaperInputFile);
</script>
</dom-module>