繁体   English   中英

自定义库中的Polymer.dart propertyNameChanged方法不起作用

[英]Polymer.dart propertyNameChanged method in a custom library isn't working

这是我的polymer.dart类。

import 'package:polymer/polymer.dart';

/**
 * A Polymer x-changer element.
 */
@CustomTag('x-changer')

class XChanger extends PolymerElement {

  @published String prop;

  propChanged() {
    print("prop changed!");
  }

  /// Constructor used to create instance of XChanger.
  XChanger.created() : super.created() {
  }


}

这是我的项目结构:

    • chat_example
    • LIB
    • 卷筒纸
  • LIB
    • X-changer.dart
    • X-changer.html
  • 测试

当我在示例文件夹中添加x-changer.dart和x-changer.html时,它可以工作。 这是完全相同的代码,我是否缺少对聚合物元素库很重要的东西?

编辑:这是库pubspec

name: some_elements
description: >
  The polymer elements for ...
version: 0.0.1
author: Joris Hermans
#homepage: https://www.example.com
dependencies:
  polymer: '>=0.15.4 <0.16.0'
dev_dependencies:
  unittest: any

您需要在库中添加聚合物变压器(没有entry_points)。

您不应You shouldn't import like ` You shouldn't import like

它看起来应该更像

您不应该像<link rel="import" href="packages/chat_example/force/force_client_element.html">

您可能需要一个或多个其他../前缀,具体取决于导入文件所在的位置(在Dart包:xxx导入中这从来没有必要。

<link rel="import" href="../packages/chat_example/force/force_client_element.html">

有关更多详细信息,请参见https://www.dartlang.org/polymer/app-directories.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM