我有一个HTML元素,如下所示:
<!--<div id="waves"></div>-->
<script type="WaveDrom" id="waves">
{signal: [
['input' ,
{name: 'a', wave: '01010101'},
{name: 'b', wave: '0.1.0.1.'},
{name: 'c', wave: '0...1...'}],
['output',
{name: 'expected d', wave: '01.010.1'},
{name: 'simulated d', wave: '01.010.1'},
{name: 'expected e', wave: '0..101..'},
{name: 'simulated e', wave: '0..101..'}]
]}
</script>
在Dart中,我现在想要将idE'wave'替换为ScriptElement的内容。但querySelector('#waves')
不返回ScriptElement(它返回null)。如果我添加DivElement,它会发现这很好。
ScriptElements有什么特别之处,他们不能这样查询吗?或者这是Dart中的错误吗?
答案 0 :(得分:1)
我在main.dart
void main() {
var x = document.querySelector('script');
print(x.attributes['src']);
}
并在HTML文件中
<!DOCTYPE html>
<html>
<head>
<script src="packages/web_components/platform.js"></script>
<meta charset="utf-8">
</head>
<body>
<div class='target' id='target1'>ANIMATION 1</div>
<div class='target' id='target2'>ANIMATION 2</div>
<script type="application/dart" src="index.dart"></script>
<script src="packages/browser/dart.js"></script>
</body>
</html>
当我运行它时会打印
包/ web_components / platform.js