javascript – aurelia:变量未在自定义组件中打印
作者:互联网
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小时都在尝试这3天.
任何形式的帮助表示赞赏
更新:
利用welcome.html中的组件
<template>
<require from = "./components/weather.html"></require>
<weather view-model="Weather"></weather>
</template>
还将welcome.ts中的组件导入为
import { Weather } from './components/weather';
解决方法:
您不需要viewmodel,只需要视图.
<require from = "./components/weather.html"></require>
如果您同时需要视图和视图模型,请改为:
<require from = "./components/weather"></require>
标签:javascript,aurelia,aurelia-binding,aurelia-cli,aurelia-framework 来源: https://codeday.me/bug/20190701/1348410.html