问题描述
我从一些Dart示例开始。然后我想用 document.query('#someId')
查询DOM ,但似乎文档中没有查询方法。另外,通过`new Element.tag('p')创建一个新元素不起作用。
然后我发现,当我将导入的包从 dart:dom
更改为 dart:html
。但是使用它们给了我一堆 _XYZ 的重复定义。
所以我不知道:
-
dart:html
和之间有什么区别dart:dom
为什么我不能同时使用
解决方案
对所有答案的更新,可能使这个问题不再适用是dart:dom已被弃用。 p>
I'm starting with some of the Dart examples. Then I wanted to query the DOM with document.query('#someId')
as described here, but it seems there was no query method in document. Also creating a new element by `new Element.tag('p') doesn't work.
Then I figure out that it will work, when I change the imported package from dart:dom
to dart:html
. But using both of them gives me a bunch of duplicate definition of _XYZ
.
So I wonder:
- what's the difference between
dart:html
and dart:dom
package - which one should I use
- why can't I use both
解决方案 An update to all the answers, and probably makes this question no longer applicable is that dart:dom has been deprecated.
See this post on dartlang website.
这篇关于“dart:html”和“dart:html”之间有什么区别?和“dart:dom”包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!