Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 聚合物0.8:在<;内容>;选择不工作的属性_Javascript_Polymer - Fatal编程技术网

Javascript 聚合物0.8:在<;内容>;选择不工作的属性

Javascript 聚合物0.8:在<;内容>;选择不工作的属性,javascript,polymer,Javascript,Polymer,在polymer 0.5中,我可以直接使用“选择”属性中的属性,并正确过滤节点 在polymer 0.8中,如果我尝试使用数据绑定,它将无法工作 <dom-module id="test-element"> <template> <content id="p0" select="[selected-item]"></content> <span>{{selector}}</span>

在polymer 0.5中,我可以直接使用“选择”属性中的属性,并正确过滤节点

在polymer 0.8中,如果我尝试使用数据绑定,它将无法工作

<dom-module id="test-element">
    <template>
        <content id="p0" select="[selected-item]"></content>
        <span>{{selector}}</span>
        <content id="p1" select="{{selector}}"></content>
    </template>
</dom-module>
<script>
    Polymer({
        is: 'test-element',
        properties: {
            selector: {
                type: 'String',
                value: '[selected-item]'
            }
        },
        ready: function() {
            console.log(
                //show: 3
                Polymer.dom(this.$.p0).getDistributedNodes().length,
                //show: 6
                Polymer.dom(this.$.p1).getDistributedNodes().length
            );
        }
    });
</script>

<test-element>
    <div selected-item>1</div>
    <div>2</div>
    <div selected-item>3</div>
    <div selected-item>4</div>
</test-element>

{{选择器}}
聚合物({
是:'测试元素',
特性:{
选择器:{
键入:“字符串”,
值:“[所选项目]”
}
},
就绪:函数(){
console.log(
//节目:3
Polymer.dom(this.$.p0).getDistributedNodes().length,
//节目:6
Polymer.dom(this.$.p1).getDistributedNodes().length
);
}
});
1.
2.
3.
4.

这是个坏主意吗?有人成功了吗?

0.8数据绑定中的SAI默认为单向。我还没有使用0.8,但一定要看一看。我会验证。doc指定两个数据绑定必须在定义中使用{{}和notify:true。但事实上,这并没有改变我的问题。顺便说一下,如果您试图显示该元素,您将看到{{selector}}在中正确显示,这意味着它在localDOM中显示,但不影响过滤。