reverse-name/dart-js/test.dart

36 lines
742 B
Dart
Raw Normal View History

2024-03-04 19:03:46 +08:00
// js
2024-03-04 22:46:12 +08:00
import 'dart:js' as Js;
import 'dart:html';
2024-03-04 19:03:46 +08:00
2024-03-04 12:29:26 +08:00
void main() {
2024-03-04 22:52:37 +08:00
// Find an element by id (an-id).
Element idElement = querySelector('#an-id')!;
// Find an element by class (a-class).
Element classElement = querySelector('.a-class')!;
// Find all elements by tag (<div>).
List<Element> divElements = querySelectorAll('div');
2024-03-04 12:29:26 +08:00
print("Hello, World!");
var a = "Hello, World!";
for (var i = 0; i < 10; i++) {
a += " " + i.toString();
}
2024-03-04 22:52:37 +08:00
int b = 124242424;
2024-03-04 12:29:26 +08:00
for (var i = 0; i < 10; i++) {
2024-03-04 22:52:37 +08:00
b += b * i;
2024-03-04 12:29:26 +08:00
}
2024-03-04 22:52:37 +08:00
// js sleep
Future.delayed(Duration(milliseconds: 1000)).then((value) {
print("延时1秒执行 then ");
print(value);
});
2024-03-04 22:46:12 +08:00
var closuer = () {
print("closuer");
};
closuer();
2024-03-04 12:29:26 +08:00
print(a);
2024-03-04 22:52:37 +08:00
}