[英]How to get properties in Polymer content element?
Probably something super easy, but I seem unable to find the answer. 可能超级简单,但我似乎找不到答案。
I would like to replace the properties in the <content>
section. 我想替换
<content>
部分中的属性。 But I don't understand how to push the title
(with content hola
) to the <content>
section. 但是我不明白如何将
title
(带有content hola
)推送到<content>
部分。
demo-app.html demo-app.html
<dom-module id="demo-app">
<template>
<style>
:host {
display: block;
}
</style>
<my-el>
[[title]] or {{title}}
</my-el>
</template>
...
my-el.html my-el.html
<link rel="import" href="../../bower_components/polymer/polymer.html">
<dom-module id="my-el">
<template>
<style>
:host {
display: block;
}
</style>
<content></content>
</template>
<script>
Polymer({
is: 'my-el',
properties: {
title: {
type: String,
value: 'hola',
},
}
})
</script>
</dom-module>
PS: PS:
I'm 99% sure there are some docs that I'm missing... Any link is welcome :-P 我99%肯定有一些文档不见了...欢迎任何链接:-P
That's technically possible if <demo-app>
had its own title
property that you bound to <my-el>.title
like this: 如果
<demo-app>
具有您自己绑定到<my-el>.title
的title
属性,这在技术上是可行的:
<dom-module id="demo-app">
<template>
<my-el title="{{title}}">
[[title]] or {{title}}
</my-el>
...
HTMLImports.whenReady(() => { Polymer({ is: 'my-el', properties: { title: { type: String, value: 'Hello world!', notify: true } } }); Polymer({ is: 'demo-app' }); });
<head> <base href="https://polygit.org/polymer+1.7.0/components/"> <script src="webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="polymer/polymer.html"> </head> <body> <demo-app></demo-app> <dom-module id="demo-app"> <template> <style> h1 { color: blue; } </style> <my-el title="{{title}}"> <h1>[[title]]</h1> </my-el> </template> </dom-module> <dom-module id="my-el"> <template> <content></content> <section> <input type="text" value="{{title::input}}"> </section> </template> </dom-module> </body>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.