工作:(文档有一个img标签,id ="img"src ="img.png",它有效)
void test() {
ImageElement img = query('#img');
context.drawImage(img, 0, 0);
}
Run Code Online (Sandbox Code Playgroud)
不工作:
void test() {
ImageElement img = new ImageElement(src: 'img.png');
context.drawImage(img, 0, 0);
}
Run Code Online (Sandbox Code Playgroud)
那么,为什么我不能在文档中使用'new ImageElement'而不是'query'?