2016-08-20 50 views

回答

1

我怀疑其不可能的,因为对于数据结合工作,所述元件(或与所述的textContent元件)需要已经从聚合物,这当然headtitle不是继承。

你可以做的是创建一个放置在主体中的元素(<proxy-title>?),并且在观察者中以编程方式在dom中定位标题元素并写入它拥有的标题属性。

喜欢的东西

<dom-module id="proxy-title"> 
    <template> 
    <style> 
     :host { 
     display:none; 
     }; 
    </style> 
    </template> 
    <script> 
    Polymer({ 
     is: 'proxy-title', 
     properties: { 
     title: { 
      type: String, 
      value: '', 
      observer: '_titleChanged' 
     } 
     }, 
     _titleChanged: function(title) { 
     document.title = this.title; 
     } 

    }); 
    </script> 
</dom-module> 

你会使用它,像这样

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<title></title> 
<!-- other head stuff --> 
</head> 
<body> 
    <proxy-title title="[[someTitle]]"></proxy-title> 

    <!-- ... other stuff here --> 

</body> 
</html> 
+0

谢谢akc42。将测试这一次回家! – willsquire

相关问题