2013-06-18 5 views
1

짧은 버전 : 첫 번째 링크의 사용자 지정 웹 구성 요소 예제가 저에게 맞지 않습니다. 왜 안돼? Dartium에서 실행하고 있습니다.간단한 다트 웹 구성 요소가 작동하지 않습니다.

긴 버전 : 나는 복사 다트 편집기로 this tutorial에서 this 다트 웹 UI 예를 붙여 그것을 실행하려고. 그 페이지에는 아무 것도 나타나지 않았다. 전에는 웹 컴포넌트가 아닌 다트를 사용 했으므로이 코드와 내가 작성한 다른 코드의 차이점은 <script src="packages/browser/dart.js"></script>이 없었기 때문에 맨 아래에 추가했음을 알았습니다.

 
Internal error: Dart_Invoke: did not find top-level function 'main'. 

내가 main() 기능에 print 문을 넣어 텍스트가 이상하다 오류, 전에 인쇄했다 : 지금은 오류가 발생했습니다. 사용자 지정 구성 요소에있는 <script> 태그 안에 main() {}을 추가하려고했습니다. 즉, 스크립트 태그는 다음과 같이 보입니다.

<script type="application/dart"> 
    import 'package:web_ui/web_ui.dart'; 

    main() {print("in main in component");} 
    class CounterComponent extends WebComponent { 
    int count = 0; 
    void increment() { count++; } 
    } 
</script> 

오류가 사라지고 인쇄 문이 인쇄되지만 아무 것도 표시되지 않습니다.

다음은 사용자의 편의를 위해 원래의 튜토리얼 코드 :

<!DOCTYPE html> 
<!-- 
Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 
for details. All rights reserved. Use of this source code is governed by a 
BSD-style license that can be found in the LICENSE file. 
--> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <link rel="stylesheet" 
    href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.css"> 
</head> 
<body> 
    <element name="click-counter" constructor="CounterComponent" extends="div"> 
    <template> 
     <button on-click="increment()">Click me</button> 
     <span>(click count: {{count}})</span> 
    </template> 
    <script type="application/dart"> 
     import 'package:web_ui/web_ui.dart'; 

     class CounterComponent extends WebComponent { 
     int count = 0; 
     void increment() { count++; } 
     } 
    </script> 
    </element> 
    <div class="well"> 
    <div is="click-counter"></div> 
    </div> 
    <script type="application/dart"> 
    main(){} 
    </script> 
</body> 
</html> 

답변

2

웹 UI 응용 프로그램은 "건설"할 필요가 (일반적으로 자세한 내용은 프로젝트 루트에서 build.dart, see this article라는 스크립트에 의해).

다트 편집기로 이동하여 마법사를 사용하여 웹 프로젝트 (web_ui 라이브러리 사용) 옵션을 선택하면 테스트 스크립트가 포함 된 상용구가 만들어집니다.

html 파일을 열고 github 튜토리얼의 코드를 붙여 넣어 이미있는 것을 대체하십시오. 파일을 저장하면 build.dart이 호출되어 빌드 버전이/web/out/

으로 실행 버튼을 클릭하면 다트 편집기가 Dartium에서 앱을 엽니 다 (/out/을 URL에 추가하는 것을 알고 있음).).

관련 문제