我正在使用https://github.com/Polymer/sampler-scaffold中的sample-scaffold,并使用app-globals定义一些全局变量,如https://www.polymer-project.org/docs/polymer/polymer.html#global
中所述像
<app-globals myvar="value"></app-globals>
<sampler-scaffold>
<core-item label="Page 1" url="page1.html"></core-item>
</sampler-scaffold>
page1.html还包含没有值的app-globals。
<app-globals id="globals"></app-globals>
但是,globals元素不包含任何值。有没有办法使用app-globals在iframe中定义全局变量?
答案 0 :(得分:0)
使用Polymer Element扩展怎么样?和继承,以保持app-globals对象的接口静态?我的Plunker:http://embed.plnkr.co/uDPTVP/preview
应用-config.html 强>
<!-- per https://www.polymer-project.org/docs/polymer/polymer.html#extending-other-elements -->
<link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html">
<link rel="import" href="app-globals.html">
<polymer-element name="app-config" extends="app-globals">
<script>
Polymer({
ready: function () {
this.super();
this.values.GloabalSettingsVal1 = "GDG FTW"
}
});
</script>
</polymer-element>