typescript - `not a module` - 接口分配错误
问题描述
我正在尝试将界面添加到我的应用程序组件中。得到错误interface.ts is not a module
- hot 来解决这个问题。
我的 appComponent.ts:
import { Component } from "@angular/core";
import { Name } from "./interface";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
name:Name = "CodeSandbox";
}
我的界面.ts:
export interface Name {
name: string;
}
我的代码有什么问题?谁能帮我?
解决方案
您的接口文件名必须与您的接口名称匹配。所以你必须将你的接口文件重命名为我的 Name.ts:
export interface Name {
name: string;
}
和
import { Name } from "./Name ";
推荐阅读
- android - 如何在android自定义搜索栏中设置工具提示文本?
- laravel-5 - 刀片模板中的 Shopify Assets API 意外常量
- go - 如何设置界面的字段?
- .net-core - 如何从 dotnet core 中的发布中排除语言 dll
- google-api - 我如何知道 gmail-api 的版本是否更改?
- flutter - 在虚拟化 OSX 上将 Flutter 应用程序运行到 iOS 虚拟设备中
- php - 检查最终金额是否允许接受 PHP 中可用的国家/地区面额
- azure-data-explorer - 将具有不同字段的不同 csv 提取到 ADX 表中
- regex - 使用正则表达式在标识符之间提取字符串
- robotframework - 在测试用例报告中创建日志链接