2015-03-19 32 views
1
  1. 創建一個默認POLYMERE web應用程序
  2. 刪除main_app.html幾行這個

不能得到重複的鏢聚合物的webapp

<link rel="import" href="../../packages/polymer/polymer.html"> 
 

 
<polymer-element name="main-app"> 
 
    <template> 
 
    <style> 
 
     :host { 
 
     display: block; 
 
     } 
 
    </style> 
 
    </template> 
 
    <script type="application/dart" src="main_app.dart"></script> 
 
</polymer-element>

工作
  1. 像這樣更改main_app.dart的內容

import 'package:polymer/polymer.dart'; 
 

 

 
class Project extends Observable 
 
{ 
 
    Project(this.name, this.dateCreated); 
 
    @published var name; 
 
    @published var dateCreated; 
 
} 
 

 
@CustomTag('main-app') 
 
class MainApp extends PolymerElement { 
 
    
 
    /// Constructor used to create instance of MainApp. 
 
    MainApp.created() : super.created() 
 
    { 
 
     
 
    } 
 
    
 
     /// Called when an instance of main-app is inserted into the DOM. 
 
     attached() { 
 
     createModelObjects(); 
 
     super.attached(); 
 
     } 
 
    
 
     /// Called when an instance of main-app is removed from the DOM. 
 
     detached() { 
 
     super.detached(); 
 
     } 
 
    
 
    @published List<Project> projects = new List(); 
 
    
 
    void createModelObjects() { 
 
     projects.add(new Project("InterSections Santa Rosa South inspection", new DateTime.now())); 
 
     projects.add(new Project("Playground Inspections Healdsburg ", new DateTime.now())); 
 
     projects.add(new Project("Pothole inspection Bloomfield Rd Sebastopol", new DateTime.now())); 
 
    } 
 
}

  • 設定在Dartium或JavaScript createModel對象和運行的index.html一個斷點。這個斷點打了三次,爲什麼?
  • 如何在斷點在webapp/dart編輯器中點擊時看到跟蹤。 enter image description here
  • 現在我的第二個問題,在main_app.html更改模板這樣:
  • <template> 
     
        <style> 
     
         :host { 
     
         display: block; 
     
         } 
     
        p { 
     
         margin: 20px; 
     
         padding: 80px 20px; 
     
         border-radius: 20px; 
     
         background-color: #eee; 
     
        } 
     
        </style> 
     
        
     
         <table> 
     
          <tr template repeat="{{project in projects}}"> 
     
          <td> <p>Name and Date 
     
              {{name}} 
     
              {{dateCreated}}</p></td> 
     
           
     
          </tr> 
     
         </table> 
     
        </template>

  • 重新啓動,我看到什麼都沒有 - 我期望一個項目元素表 我錯過了什麼?

  • 我在dartium中運行調試工具並查看以下元素 如何查看代碼片段? enter image description here

  • 不確定推薦的方法是調試這種情況。有什麼幫助嗎?

  • +0

    你使用什麼聚合物版本? – 2015-03-19 05:02:51

    +0

    0.15.5 + 4(多數民衆贊成在包文件夾下看到)。我剛剛重新安裝了Dart Editor。我在Windows 7下運行 – 2015-03-19 05:30:25

    +0

    我認爲綁定'{{name}}'應該是'{{project。名稱}}(與dateCreated相同) – 2015-03-19 05:55:16

    回答

    1

    4)我不能再現

    5)當調試器遇到斷點調試器視圖顯示調用堆棧。看起來很明顯,因此很難解釋。您在調試器視圖中看不到調用堆棧,或者根本沒有調試器視圖? 爲了獲得更好的堆棧跟蹤檢查How to get the full stack trace for async execution(僅打印)

    6,7),這爲我工作

    <table> 
        <tr template repeat="{{project in projects}}"> 
        <td><p>Name and Date 
         {{project.name}} 
         {{project.dateCreated}}</p></td> 
    
        </tr> 
    </table> 
    

    project領域需要有一個觀察的集合,使得聚合物獲取有關更改名單的通知

    @published List<Project> projects = new List(); 
    

    8)你不能 如果你檢查你上面的<div hidden>發現這個元素的使用模板的詳細信息。

    9) 我有一個例外,當我想你的代碼,而{{project....}}

    額外提示:

    使用@observable代替@published。如果僅從該組件內綁定字段,則也可以使用@observable而不是@published。

    +1

    至第4)抱歉,這是一個愚蠢的用戶錯誤。我在Visual Studi中工作了很長時間,並假定播放按鈕也是連續按鈕。點擊幾次使其看起來像斷點再次被擊中。普通老用戶錯誤 – 2015-03-19 16:31:15

    +0

    編號5)我添加了一個圖像上面我的調試器窗口的樣子。我沒有看到一絲痕跡。 – 2015-03-19 16:42:44

    +0

    上半部分是痕跡。你在這裏錯過什麼? – 2015-03-19 16:46:19