aurelia:自定义组件中未打印变量

aurelia: variable is not getting printed in custom component

weather.ts 文件

import {bindable} from 'aurelia-framework';

export class Weather {
  cityName: string = 'Hilsinki';
  constructor() {
    this.cityName = 'Hilsinki';
  }
}

weather.html 文件

<template>
        City XName: ${cityName}
</template>

当我打印任何文件中的组件时,cityName 变量没有被打印出来。我在过去三天每天 12 小时都在尝试这个。

感谢任何形式的帮助

更新: 利用 welcome.html

中的组件
<template>
    <require from = "./components/weather.html"></require>
    <weather view-model="Weather"></weather>
</template>

还将welcome.ts中的组件导入为

import { Weather } from './components/weather';

您没有 require 视图模型,只有视图。

<require from = "./components/weather.html"></require>

如果您同时需要视图和视图模型,请改为这样要求:

<require from = "./components/weather"></require>