我创建了一个 Dart 应用程序并从一些天气 API 源中获取天气信息。
只是出于好奇,我想测试一下是否可以将天气信息封装在一个对象中,然后在 Polymer 模板中渲染该对象的属性。
片段是这样的:
HTML 文件:
<polymer-element ...>
<template>
Today in {{weather.city}}, the temperature is {{weather.temp}}.
</template>
</polymer-element>
和飞镖文件:
@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 文件,它很糟糕:根本没有显示。