LoginSignup
0
0

More than 1 year has passed since last update.

Srcフォルダ (world.ts と、index.ts) のメモ

Posted at

#Hello World の出し方

world.ts

export default class World {
  // クラスで使うプロパティ、World というクラスを作る
  message: string;


  constructor(message: string) {
    this.message = message
  }
  // コンストラクタ messageの値は何ですか? といった、初期化のようなものを行なっている(初期化) 


  // 外部から呼び出せるメソッドを定義
  public sayHello(elem: HTMLElement | null) {
    if (elem) {
      elem.innerText = this.message
    }
  }
}
index.ts
import World from './world';

const root: HTMLElement | null = document.getElementById("root")
const world = new World("Hello World!!!");
world.sayHello(root);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0