如何创建与另一个类/接口同名的类?

时间:2012-06-29 03:07:11

标签: dart

我想创建自己的名为Point的类,但是遇到了html库中同名接口的问题。我错过了什么会让我脱离“已经定义为界面”的泡菜?

class Point
{
//r is x
// g is the difference between x+y and 0
// b is y
  num r,g,b;
  Point(this.r, this.g, this.b);
...
}
  

内部错误:   'http://127.0.0.1:3030/C:/Users/.../Desktop/dart/workspace/projects/.../Point.dart':错误:第1行pos 7:'Point'已定义作为接口类   点

1 个答案:

答案 0 :(得分:1)

导入具有要重用的类/接口的库时,请使用前缀限定它,这将强制您明确使用原始类,并将隐式使用新类。

#import('dart:html', prefix:'html');

html.Point将在html中使用点接口 Point将使用项目/库中的类。