Dartweb Basics-Easy to get started
In front of the dartweb is dart, so we need to build the DART development environment before doing the following
Download Dartium Browser
Dartium is a special version of chromium that contains the dart VM, and using dartium means you don't have to compile the code into JavaScript to debug the program until the development is complete and then compile the code into JavaScript to test other browsers
dartium-Portal
For later convenience development, you can set up a shortcut to the desktop
Create and refine your app
Create a new index.html file under the root directory
<! DOCTYPE html><html><head> <title>TestWeb</title></head><body> <p id="pid"></P> <script type="Application/dart" src="Main.dart"> </script></body></html>
Then create a new Main.dart file in the root directory
// dart:html中包括DOM元素类型、CSS样式、本地存储、媒体、语音、事件等import"dart:html";void main() { querySelector("#pid""Hello World!";}
Code simple diagram
Debugging with Dartium
Open index.html in Dartium to check the performance of the code execution. Now open with another browser, there is no effect
Dart file to JS file
Since no browser supports dart at this time, you can only use the DART2JS directive to convert the dart file to a JS file and replace the Dart file to publish the project
Execute the DART2JS command under the root directory
dart2js --out=main.js main.dart
After execution, three files are generated, but only one main.js file is actually useful
Copy the index.html file and rename it to index2js.html, and then modify the code to replace the DART reference with a JS reference
<! DOCTYPE html><html><head> <title>TestWeb</title></head><body> <p id="pid"></P> <script type="text/javascript" src="Main.js"></script></body></html>
You can now open the index2js.html file using any browser
Dartweb Basics-Easy to get started