问题描述
有没有办法绑定点击
或点击
事件<< ;纸张按钮>
添加到以下任何一个隐藏
输入
元素?
Is there any way to bind an on-click
or on-tap
event of a <paper-button>
to either of the following hidden
input
elements?
<iron-form>
<form>
...
<my-buttons></my-buttons>
...
<input hidden type="reset">
<input hidden type="submit">
</form>
<iron-form>
或者以任何方式触发这些事件?即,我已经从我的< paper-button>
派发了一个事件如下
my-buttons.html
Or to trigger those events in any way? i.e., I have dispatched an event from my <paper-button>
as follows
<paper-button on-tap="_reset">Reset</paper-button>
<paper-button on-tap="_save">Save</paper-button>
<script>
_reset() {
// dispatchEvent...
}
_save() {
// dispatchEvent...
}
</script>
我想给我显示给我的用户的按钮添加漂亮的(Material Design) code>< iron-form> 。
I want to give pretty (Material Design) styling to the buttons I display to the user of my <iron-form>
.
I am also watching @notwaldorf's (Monica D's) tutorial here.
推荐答案
您并不需要那些隐藏的输入,因为< iron-form>
为等效事件提供了一个API。即,和:
You don't really need those hidden inputs, as <iron-form>
provides an API for the equivalent events. Namely, <iron-form>.submit()
and <iron-form>.reset()
:
// <iron-form id="form">
_reset() {
this.$.form.reset();
}
_submit() {
this.$.form.submit();
}
这篇关于在Polymer 2.x中设计原生输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!