提交 ba25db32 编写于 作者: fxy060608's avatar fxy060608

feat(uts): 参数支持ComponentPublicInstance

上级 25aedc80
import { isPlainObject, hasOwn, extend, capitalize, isString } from 'uni-shared';
// 生成的 uts.js 需要同步到 vue2 src/platforms/app-plus/service/api/plugin
let callbackId = 1;
let proxy;
const callbacks = {};
function isComponentPublicInstance(instance) {
return instance && instance.$ && instance.$.proxy === instance;
}
function normalizeArg(arg) {
if (typeof arg === 'function') {
// 查找该函数是否已缓存
......@@ -12,9 +16,21 @@ function normalizeArg(arg) {
return id;
}
else if (isPlainObject(arg)) {
Object.keys(arg).forEach((name) => {
arg[name] = normalizeArg(arg[name]);
});
if (isComponentPublicInstance(arg)) {
let nodeId = '';
// @ts-expect-error
const el = arg.$el;
// 非 x 可能不存在 getNodeId 方法?
if (el && el.getNodeId) {
nodeId = el.getNodeId();
}
return { nodeId };
}
else {
Object.keys(arg).forEach((name) => {
arg[name] = normalizeArg(arg[name]);
});
}
}
return arg;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册