如何在打开 paper-dialog
时将焦点集中在包含在 paper-dialog
中的 paper-input
?
我目前有这个基本代码作为概念证明,但它没有焦点。
我发现这可以与 paper-input
中编写的 autofocus
一起使用,但我认为这不是一个合适的方法。
HTML
<paper-dialog style="margin:0; padding: 0;" class="changePictureDialog" id="dialog" with-backdrop entry-animation="scale-up-animation"
exit-animation="fade-out-animation">
<paper-input style="margin:20px" id="newInput" placeholder="placeholder"></paper-input>
<paper-button id="button" on-click="focusInput">button</paper-button>
</paper-dialog>
JS
openDialog : function() {
this.$.dialog.open();
this.$.newInput.focus();
},
最佳答案
更改此:
this.$.newInput.focus();
致:
this.$.newInput.autofocus = true;
关于javascript - 打开对话框后设置焦点 - Polymer(无 JQuery),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45759656/