MCPcopy Create free account
hub / github.com/chunshand/qdev / useTransformOnBind

Function useTransformOnBind

admin/src/components/Qdev/help.ts:7–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5 * @returns
6 */
7export const useTransformOnBind = () => {
8 const { proxy, data } = getCurrentInstance() || { proxy: null };
9 const CurrentInstance = getCurrentInstance();
10 // v-当前绑定对象 item-绑定元数据 value-用户自定义传进来的数据
11 return (v: any, item: any, meta?: any) => {
12 meta ? meta = _.clone(meta) : null;
13 if (v != undefined) {
14 if (typeof v == 'function') {
15 return v(proxy, item)
16 } else if (typeof v == 'object') {
17 let _v: any = {};
18 Object.keys(v).map((k) => {
19 if (typeof v[k] == 'function') {
20 // args 事件返回数据
21 _v[k] = (...args: any[]) => {
22 return v[k].call(null, {
23 args: args,
24 that: CurrentInstance,
25 item: item,
26 meta: meta,
27 value: args.length > 0 ? args[0] : null
28 });
29 }
30 } else {
31 _v[k] = v[k];
32 }
33
34 })
35 return _v;
36 }
37 }
38 return {}
39 }
40}

Callers 1

useTableFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected