짧은 버전 : 첫 번째 링크의 사용자 지정 웹 구성 요소 예제가 저에게 맞지 않습니다. 왜 안돼? 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>