Dart Polymer 1.0 有没有办法在客户端和服务器端使用一个 "refectable" class?
Dart Polymer 1.0 is there any way to use one "refectable" class on client and server side?
在 Dart Polymer 1.0
中使用 JsProxy 启用双向绑定不允许在服务器端使用此 classes。用 JsProxy
从父 class 扩展也不能解决问题。
当我试图解决这个问题时。我创建了一个 class (在服务器端使用),然后用 JsProxy
:
从这里扩展
class Person {
@reflectable String name;
@reflectable int age;
Person(this.name, this.age);
}
class PersonModel extends Person with JsProxy {
PersonModel(name, age) : super(name, age);
}
如果我使用 set
更改值,对象 person
不会反映更改
<my-element>
<p>[[person.name]], [[person.age]]</p>
</my-element>
void main() {
PersonModel person;
set('person', new PersonModel('Tom', 23));
}
有没有办法在客户端和服务器端使用class,而不需要为客户端和服务器维护两个单独的class?也许还有其他一些方法可以解决这个问题?
根据问题 https://github.com/dart-lang/polymer-dart/issues/664 的更新,目前不支持此功能,但有计划取消此限制。
在 Dart Polymer 1.0
中使用 JsProxy 启用双向绑定不允许在服务器端使用此 classes。用 JsProxy
从父 class 扩展也不能解决问题。
当我试图解决这个问题时。我创建了一个 class (在服务器端使用),然后用 JsProxy
:
class Person {
@reflectable String name;
@reflectable int age;
Person(this.name, this.age);
}
class PersonModel extends Person with JsProxy {
PersonModel(name, age) : super(name, age);
}
如果我使用 set
person
不会反映更改
<my-element>
<p>[[person.name]], [[person.age]]</p>
</my-element>
void main() {
PersonModel person;
set('person', new PersonModel('Tom', 23));
}
有没有办法在客户端和服务器端使用class,而不需要为客户端和服务器维护两个单独的class?也许还有其他一些方法可以解决这个问题?
根据问题 https://github.com/dart-lang/polymer-dart/issues/664 的更新,目前不支持此功能,但有计划取消此限制。