Nes*_*don 4 javascript dart dart2js
我的 HTML 文档头中导入了一个 JavaScript 库。如何从该库访问对象?
谢谢。
与 JavaScript 的互操作在文章“使用 Dart 中的 JavaScript:js 库”中进行了描述
简而言之,您必须:
//import the JS interop lib
import 'package:js/js.dart' as js;
// access the JS context for the page
var context = js.context;
// then use context to access JS object
var canvas = query('#map_canvas');
var googlemaps = js.context.google.maps;
// and create JS objects accessed through proxies
var googlemap = new js.Proxy(googlemaps.Map, canvas);
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息(范围、生命周期、回调等)和示例,请参阅链接的文章。
归档时间: |
|
查看次数: |
2239 次 |
最近记录: |