【问题标题】:I used to run successfully before, Now I see runtime error the code gets compiled without an issue我以前运行成功,现在我看到运行时错误代码编译没有问题
【发布时间】:2020-05-18 22:09:26
【问题描述】:

我是 TypeScript 的新手。我正在使用 TypeScript 中的 Class,我的代码以前可以正常工作,但现在无法正常工作。它在运行时显示错误。

【问题讨论】:

  • 帮助我们帮助您 - 请将代码和错误以(格式化)文本形式分享,而不是屏幕截图。
  • 嗨 Mureinik,我已经在我的评论中发布了他的代码。请多多指教。
  • 嗨@Mureinik 你能解决这个错误吗

标签: node.js typescript npm runtime-error typescript-class


【解决方案1】:
class NewP {
    firstName : string;

    constructor(digit: string){

        this.firstName=digit;
    }

    greet(){

        return "Hi, " + this.firstName;
    }

}

let greet = new NewP("Hello");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-17
    • 2023-03-31
    • 2015-06-19
    • 1970-01-01
    • 2023-02-19
    • 1970-01-01
    • 2019-06-30
    • 1970-01-01
    相关资源
    最近更新 更多