我将客户端作为参数发送到自定义客户端后续详细信息(在home.html中)并在“client_followup_detail.html”中显示他们的信息,但是当我尝试从“client_followup_detail.dart”异常访问客户端属性时发生。
home.html的
<template repeat="{{index in extraTabsIndex}}">
<template if="{{activeTab == index}}">
<div class="tab-pane fade in active">
<p>
<client-followup-detail client="{{clientSelect}}"></client-followup-detail>
</p>
</div>
</template>
client_followup_detail.html
<td>{{client.state}}</td>
<td>{{client.cellphone}}</td>
<td>{{client.lastContactDate}}</td>
client_followup_detail.dart
@published Client client;
ClientFollowupDetail.created() : super.created() {
eventBus = getInstanceEventBus();
print(client.names); // client null
}
错误:
Exception: The null object does not have a getter 'names'.
NoSuchMethodError : method not found: 'names'
Receiver: null
Arguments: []
答案 0 :(得分:3)
ClientFollowupDetail实例可能未被聚合物完全初始化。
将create
代码移到ready
:
ready() {
super.ready();
eventBus = getInstanceEventBus();
print(client.names);
}