聚合物1.0:与<铁 - 元素的数据结合变量>元素(值属性) [英] Polymer 1.0: Data binding variable to &lt;iron-meta&gt; element (value attribute)

查看:146
本文介绍了聚合物1.0:与<铁 - 元素的数据结合变量>元素(值属性)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在聚合物1.0中,我试图将一个字符串变量 {{str}} 的数据绑定到一个< iron-meta> 元素(父元素中的标签)如下。



失败:

 < iron-meta id =metakey =infovalue ={{str}}>< / iron-meta> 

上述代码中断。但是以下代码的工作原理(没有绑定)。



这样做:

 < iron-meta id =metakey =infovalue =foo / bar>< / iron-meta> 

区别在于变量版本 {{str}} 失败,常量版本foo / bar的作品。



有没有人有提示什么是打破绑定和如何解决?



针对评论问题编辑:


  1. 如何失败?这无声无息。我打印出的数值根本不会更新,当我按登录和注册按钮。


  2. 以下是Github存储库中代码的链接。请参阅



您需要使用属性绑定,而不是绑定属性

 < input type =textvalue $ ={{str}}/> 


In Polymer 1.0, I am trying to data bind a string variable {{str}} to an <iron-meta> element (tag in parent element) as follows.

This fails:

<iron-meta id="meta" key="info" value="{{str}}"></iron-meta>

The above code breaks. But the following code works (without the binding).

This works:

<iron-meta id="meta" key="info" value="foo/bar"></iron-meta>

The difference is the variable version {{str}} fails and the constant version "foo/bar" works.

Does anyone have a clue what is what is breaking the binding and how to fix it?

Edits in response to comment questions:

  1. How does it fail? This fails silently. The values I have printed out simply do not update when I press the Login and Register buttons.

  2. Here is a link to the code in a Github repository. See lines

解决方案

You need to use an attribute binding and not a property binding

<input type="text" value$="{{str}}" />

这篇关于聚合物1.0:与<铁 - 元素的数据结合变量>元素(值属性)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆