提交 7603d337 编写于 作者: Q qiang

fix(App): component.is support ComponentDefinition | ComponentConstructor (question/140044)

上级 f074e4e1
......@@ -155,6 +155,11 @@ function setData (id, name, value) {
break
case V_FOR:
return setForData.call(this, id, value)
case 'is': {
if (typeof value === 'function') {
value = value.options
}
}
}
return ((this._$newData[id] || (this._$newData[id] = {}))[name] = value)
......
......@@ -114,7 +114,18 @@ function vdSync ({
function getData (id, name) {
try {
return this.$r[id][name]
const data = this.$r[id][name]
if (name === 'is' && typeof data === 'object') {
const components = this.$options.components || {}
for (const key in components) {
const value = components[key]
const options = typeof value === 'function' ? value.options : value
if (options.__file === data.__file) {
return options
}
}
}
return data
} catch (e) {
// console.error(this.$options.__file + `:[${this._$id}]$r[${id}][${name}] is undefined`)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册