From 2aa9ab5af00f64866f30c80dc12781c809aff271 Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 4 Sep 2023 11:25:17 +0800 Subject: [PATCH] =?UTF-8?q?render=E5=A2=9E=E5=8A=A0=E5=AE=B9=E9=94=99?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index e8bc77b..685417b 100644 --- a/src/index.js +++ b/src/index.js @@ -376,11 +376,15 @@ export class Component extends HTMLElement { // 渲染视图 #render() { - let ast = this.render() - this[__children__] = render(ast, this.root, { - host: this, - isConnected: !this[__mounted__] && this.isConnected - }) + try { + let ast = this.render() + this[__children__] = render(ast, this.root, { + host: this, + isConnected: !this[__mounted__] && this.isConnected + }) + } catch (err) { + console.error(err) + } } // 几个生命周期回调 created() {}