Dartweb Basics-Easy to get started

Source: Internet
Author: User

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


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.