簡體   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