[英]How to use Paper-Dialog in Polymer 1.0?
I think this post relates to Polymer 0.5 and seems not to work in Polymer 1.0. 我认为这篇文章与Polymer 0.5有关,似乎不适用于Polymer 1.0。 For a beginner like me, I see no clear implementation; 对于像我这样的初学者,我看不到明确的实现方式。 just the actual function code and not a "How to". 只是实际的功能代码,而不是“如何”。 Here is my simple setup that does not work (assume I have imported all elements): 这是我无法使用的简单设置(假设我已导入所有元素):
<dom-element id="my-app">
<template>
<paper-button raised id="toggleDialog"></paper-button>
<paper-dialog entry-animation="scale-up-animation"
exit-animation="fade-out-animation" onclick="{{toggleDialog}}">
<h2>Header</h2>
<div>Dialog body</div>
</paper-dialog>
</template>
<script>
Polymer({
is: "my-app",
properties: {
type: String,
observer: "" // not important for this example so it's empty.
},
// should I put the function here?
toggleDialog: function() {
this.$.dialog.toggle();
}
});
</script>
</dom-element>
I hope I am not doing something wrong. 我希望我没有做错什么。
Replace: 更换:
this.$.dialog.toggle();
with: 有:
this.$.toggleDialog.toggle();
because: 因为:
The string after the cash sign $
needs to match the id
. 现金符号$
之后的字符串必须与id
匹配。
And, finally: 最后,
Move the id="toggleDialog"
attribute from the <paper-button>
tag to the <paper-dialog>
tag. 将id="toggleDialog"
属性从<paper-button>
标记移至<paper-dialog>
标记。 Because you want to target the <paper-dialog>
element with the .toggle()
method. 因为您想使用.toggle()
方法定位<paper-dialog>
元素。 Not the <paper-button>
itself. 不是<paper-button>
本身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.