【发布时间】:2014-01-10 17:50:24
【问题描述】:
我创建了一个 Dart 应用程序并从一些天气 API 源中获取天气信息。
出于好奇,我想测试一下是否可以将天气信息封装在一个对象中,然后在 Polymer 模板中渲染该对象的属性。
sn-p 是这样的:
HTML 文件:
<polymer-element ...>
<template>
Today in {{weather.city}}, the temperature is {{weather.temp}}.
</template>
</polymer-element>
还有 Dart 文件:
@published Weather weather;
...
weather=new Weather.created(a_json_string);
class Weather
{
String city;
num temp;
// The constructor just creates an instance by extracting the city, temp info fromthe JSON string
}
在 Dartium 中,它工作得非常好。
但是,如果我发布构建该应用程序并尝试运行该输出 HTML 文件,那就糟透了:根本没有显示。
【问题讨论】: