vscode引入dart html,visual studio code - How to fix find error for dart:html in VSCode? - Stack Overfl...

I try to run in VSCode a simple dart program with

import 'dart:html';

clause.

import 'dart:html';

// import 'package:html/dom.dart';

// import 'package:html/dom_parsing.dart';

// import 'package:html/parser.dart';

void main() async{

var myTable = new TableElement()

..setAttribute('border','1');

// ..setAttribute(name, value);

...

In Run mode (I use VSCode extension "Code Runner 0.9.9") and in Debug appeared the same error:

Error: Not found: 'dart:html'

import 'dart:html';

I have installed Dart SDK 2.3.1 at Windows10 and not installed Flutter at all.

PATH pointed to Dart SDK bin directory

PATH =D:\Dart\dart-sdk\bin;

*) At project directory I try to add additional directive at pubspec.yaml

dependencies:

----

name: main

description: Test App sample22

dependencies:

html:

---

After "pub get" command I'll see that html present but error still persist.

pub get

Resolving dependencies...

+ charcode 1.1.2

+ csslib 0.16.0

+ html 0.14.0+2

+ path 1.6.2

+ source_span 1.5.5

+ term_glyph 1.1.0

Changed 6 dependencies!

*) My next step was to import html parts via "package:html/" (marked as comments in code sample). It is not helped and required class TableElement still unrecognizable.

"main.dart:8:19: Error: Method not found: 'TableElement'."

*) I try to change "launch.json" string from

default

"program": "bin/main.dart",

to

"program": "D:/Dart/WRK03t/main.dart",

And rename my code file to "main.dart"

*) Also I try to remove Dart extension from VSCode, restart PC and install it again. it's not helped.

But let me say that when I compile main.dart to js

"dart2js -m -o tst.js main.dart"

Resulted tst.js run correctly within the html page.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值