Uncaught TypeError: невозможно прочитать свойство 'append', равное null, в машинописном тексте - PullRequest
1 голос
/ 08 мая 2020

Я получаю:

Uncaught TypeError: невозможно прочитать свойство 'append', равное null, в машинописном тексте

export class UserForm {
  constructor(public parent: Element) {}

  template(): string {
    return `
        <div>
        <h1> User Form</h1>
        <input/>
        <div>
        `;

  }

  render(): void {
    const templateElement = document.createElement('template');
    templateElement.innerHTML = this.template();
    console.log(this.parent);
    this.parent.append(templateElement.content);
  }
}

1 Ответ

0 голосов
/ 08 мая 2020

Попробуйте присвоить начальное значение, например:

constructor(public parent: Element) {
  this.parent =[];
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...