类JsObject没有构造函数jsify

时间:2013-12-03 15:37:18

标签: dart dart-editor

我正在尝试使用Dart执行地图示例。但是我收到了一个错误 类JsObject没有构造函数jsify 我正在使用的飞镖码是

library google_maps;

import 'dart:html' show query;
import 'dart:js' show context, JsObject;

void main() {
  // The top-level getter context provides a JsObject that represents the global
  // object in JavaScript.
  final google_maps = context['google']['maps'];

  // new JsObject() constructs a new JavaScript object and returns a proxy
  // to it.
  var center = new JsObject(google_maps['LatLng'], [-34.397, 150.644]);

  var mapTypeId = google_maps['MapTypeId']['ROADMAP'];

  // new JsObject.jsify() recursively converts a collection of Dart objects
  // to a collection of JavaScript objects and returns a proxy to it.
  var mapOptions = new JsObject.jsify({
      "center": center,
      "zoom": 8,
      "mapTypeId": mapTypeId
  });

  // Nodes are passed though, or transferred, not proxied.
  new JsObject(google_maps['Map'], [query('#map-canvas'), mapOptions]);
}

pubspec.yaml是

name: google_maps_api_with_dart_js
description: An app that displays a location using the JavaScript
    Google Maps API that is called using the dart:js library.
dependencies:
  browser: ">=0.9.0 <0.10.0"
environment:
  sdk: ">=0.8.10+6 <2.0.0"

1 个答案:

答案 0 :(得分:1)

我通过转换到新版本来解决这个问题

Dart编辑器版本1.0.0_r30188(稳定版)    Dart SDK版本1.0.0.3_r30188

现在一切正常。

谢谢!