Html 如何修复此条件将始终返回false
任何人都知道我为什么会遇到这种情况,都会返回“false”,因为在我尝试查看charTypeEnum是否等于ChartType.text时,“typeof ChartType”和“ChartType”类型没有重叠 图表设计Html 如何修复此条件将始终返回false,html,angular,typescript,angular-material,Html,Angular,Typescript,Angular Material,任何人都知道我为什么会遇到这种情况,都会返回“false”,因为在我尝试查看charTypeEnum是否等于ChartType.text时,“typeof ChartType”和“ChartType”类型没有重叠 图表设计 import { ChartType, ChartData, TextData } from 'src/app/mam-chart/models'; export class ChartDesignComponent implements OnInit { chartT
import { ChartType, ChartData, TextData } from 'src/app/mam-chart/models';
export class ChartDesignComponent implements OnInit {
chartTypeEnum = ChartType;
}
setupTypes() {
// I got error over here
if (this.chartTypeEnum == ChartType.text) {
this.cardJsonV2 = JSON.stringify(this.chartData);
}
}
mam-model.ts
export enum ChartType {
chart = 1,
text,
grid
}
Chart-Design.html
<mat-form-field appearance="fill">
<mat-label>Text</mat-label>
<input matInput [ngModel]="chartData?.textData?.text" />
</mat-form-field >
使用打字
if (String(this.chartTypeEnum) === ChartType.text)) {
使用打字
if (String(this.chartTypeEnum) === ChartType.text)) {
尝试将chartTypeEnum=ChartType替换为chartTypeEnum:ChartType
chartTypeEnum=ChartType时,ChartType的类型是否错误?分配给变量chartTypeEnum,而不是定义类型。尝试将chartTypeEnum=ChartType替换为chartTypeEnum:ChartType
chartTypeEnum=ChartType时,ChartType的类型是否错误?分配给变量chartTypeEnum,而不是定义类型。您好,谢谢您的回答,但现在我得到的是Stringthis.chartTypeEnum==ChartType.text。。你知道我为什么会得到这个吗?如果你在做检查的话,应该是===谢谢你的回答,但是现在我得到的是if Stringthis.chartTypeEnum==ChartType.text。。你知道我为什么会得到这个吗?如果你在检查的话,应该是