Polymer 对数组中的条件使用dom if

Polymer 对数组中的条件使用dom if,polymer,polymer-1.0,Polymer,Polymer 1.0,在0.5中,我可以使用dom中的表达式来选择数组中的某些内容,同时循环遍历它们。如何在1.0中实现相同的效果?您使用的函数如下 hasPersonLabel: function (labels) { if (labels.indexOf("Person") === -1) { return false } return true } 然后你可以使用 <template is="dom-repeat" items="{{records}}">

在0.5中,我可以使用dom中的表达式来选择数组中的某些内容,同时循环遍历它们。如何在1.0中实现相同的效果?

您使用的函数如下

hasPersonLabel: function (labels) {
    if (labels.indexOf("Person") === -1) {
        return false
    }
    return true
}
然后你可以使用

<template is="dom-repeat" items="{{records}}">
    <template is="dom-if" if="{{isPerson(item.labels)}}">

您使用的函数如下

hasPersonLabel: function (labels) {
    if (labels.indexOf("Person") === -1) {
        return false
    }
    return true
}
然后你可以使用

<template is="dom-repeat" items="{{records}}">
    <template is="dom-if" if="{{isPerson(item.labels)}}">

您使用的函数如下

hasPersonLabel: function (labels) {
    if (labels.indexOf("Person") === -1) {
        return false
    }
    return true
}
然后你可以使用

<template is="dom-repeat" items="{{records}}">
    <template is="dom-if" if="{{isPerson(item.labels)}}">

您使用的函数如下

hasPersonLabel: function (labels) {
    if (labels.indexOf("Person") === -1) {
        return false
    }
    return true
}
然后你可以使用

<template is="dom-repeat" items="{{records}}">
    <template is="dom-if" if="{{isPerson(item.labels)}}">

使用
dom repeat
filter/observe
功能比嵌套
dom if
更有效
filter
指定一种方法,用于标识要从集合中显示的记录,
observe
告诉
dom repeat
要观察哪些数据,以知道何时重新运行筛选器。例如

<template is="dom-repeat" items="{{records}}" filter="hasPersonLabel" observe="item.labels">
...
hasPersonLabel: function (labels) {
    return (labels.indexOf("Person") >= 0);
}

...
hasPersonLabel:函数(标签){
返回(labels.indexOf(“Person”)>=0);
}

文档在这里()。

使用
dom repeat
filter/observe
功能比嵌套
dom if
更有效
filter
指定一种方法,用于标识要从集合中显示的记录,
observe
告诉
dom repeat
要观察哪些数据,以知道何时重新运行筛选器。例如

<template is="dom-repeat" items="{{records}}" filter="hasPersonLabel" observe="item.labels">
...
hasPersonLabel: function (labels) {
    return (labels.indexOf("Person") >= 0);
}

...
hasPersonLabel:函数(标签){
返回(labels.indexOf(“Person”)>=0);
}

文档在这里()。

使用
dom repeat
filter/observe
功能比嵌套
dom if
更有效
filter
指定一种方法,用于标识要从集合中显示的记录,
observe
告诉
dom repeat
要观察哪些数据,以知道何时重新运行筛选器。例如

<template is="dom-repeat" items="{{records}}" filter="hasPersonLabel" observe="item.labels">
...
hasPersonLabel: function (labels) {
    return (labels.indexOf("Person") >= 0);
}

...
hasPersonLabel:函数(标签){
返回(labels.indexOf(“Person”)>=0);
}

文档在这里()。

使用
dom repeat
filter/observe
功能比嵌套
dom if
更有效
filter
指定一种方法,用于标识要从集合中显示的记录,
observe
告诉
dom repeat
要观察哪些数据,以知道何时重新运行筛选器。例如

<template is="dom-repeat" items="{{records}}" filter="hasPersonLabel" observe="item.labels">
...
hasPersonLabel: function (labels) {
    return (labels.indexOf("Person") >= 0);
}

...
hasPersonLabel:函数(标签){
返回(labels.indexOf(“Person”)>=0);
}
文档在这里()