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() {}