parent
81f8fd45eb
commit
7669b3b713
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@bd/core",
|
"name": "@bd/core",
|
||||||
"version": "1.5.8",
|
"version": "1.5.9",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "百搭UI组件库的核心",
|
"description": "百搭UI组件库的核心",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|
|
@ -106,6 +106,7 @@ export class Component extends HTMLElement {
|
||||||
this[__in_tree__] = false
|
this[__in_tree__] = false
|
||||||
// 这里提前定义一次, 是为了在connectedCallback之前, 就已有赋值时报错的bug
|
// 这里提前定义一次, 是为了在connectedCallback之前, 就已有赋值时报错的bug
|
||||||
this[__changed_props__] = new Map() // 记录一次渲染周期内变化的属性
|
this[__changed_props__] = new Map() // 记录一次渲染周期内变化的属性
|
||||||
|
// this[__init__]()
|
||||||
this.root = this.shadowRoot || this.attachShadow({ mode: 'open' })
|
this.root = this.shadowRoot || this.attachShadow({ mode: 'open' })
|
||||||
|
|
||||||
Object.defineProperty(this, '$refs', {
|
Object.defineProperty(this, '$refs', {
|
||||||
|
@ -121,9 +122,7 @@ export class Component extends HTMLElement {
|
||||||
this[__changed_props__] = new Map()
|
this[__changed_props__] = new Map()
|
||||||
// 初始化 props
|
// 初始化 props
|
||||||
this.constructor[__props__].forEach((options, prop) => {
|
this.constructor[__props__].forEach((options, prop) => {
|
||||||
// console.log(this, prop, this[prop], options.default)
|
|
||||||
this[prop] = this[prop] === void 0 ? options.default : this[prop]
|
this[prop] = this[prop] === void 0 ? options.default : this[prop]
|
||||||
// console.log('赋值后:', prop, this[prop])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 若无定义props时, 手动执行一次渲染
|
// 若无定义props时, 手动执行一次渲染
|
||||||
|
@ -250,9 +249,9 @@ export class Component extends HTMLElement {
|
||||||
|
|
||||||
// 渲染视图
|
// 渲染视图
|
||||||
[__render__]() {
|
[__render__]() {
|
||||||
let htmlText = this.render()
|
let ast = this.render()
|
||||||
|
|
||||||
this[__children__] = render(htmlText, this.root, {
|
this[__children__] = render(ast, this.root, {
|
||||||
host: this,
|
host: this,
|
||||||
isConnected: !this[__mounted__] && this.isConnected
|
isConnected: !this[__mounted__] && this.isConnected
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue