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

wip(uts): add $callMethod

上级 66224184
......@@ -150,6 +150,14 @@ function applyOptions(options, instance, publicThis) {
function set(target, key, val) {
return (target[key] = val);
}
function $callMethod(method, ...args) {
const fn = this[method];
if (fn) {
return fn(...args);
}
console.error(`method ${method} not found`);
return null;
}
function createErrorHandler(app) {
return function errorHandler(err, instance, _info) {
......@@ -267,6 +275,7 @@ function initApp(app) {
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
globalProperties.$callMethod = $callMethod;
}
{
invokeCreateVueAppHook(app);
......
......@@ -7300,6 +7300,14 @@ function applyOptions(options, instance, publicThis) {
function set(target, key, val) {
return target[key] = val;
}
function $callMethod(method, ...args) {
const fn = this[method];
if (fn) {
return fn(...args);
}
console.error(`method ${method} not found`);
return null;
}
function createErrorHandler(app) {
return function errorHandler(err, instance, _info) {
if (!instance) {
......@@ -7408,6 +7416,7 @@ function initApp$1(app) {
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
globalProperties.$callMethod = $callMethod;
}
{
uniShared.invokeCreateVueAppHook(app);
......
......@@ -14933,6 +14933,14 @@ function applyOptions(options, instance2, publicThis) {
function set(target, key, val) {
return target[key] = val;
}
function $callMethod(method, ...args) {
const fn = this[method];
if (fn) {
return fn(...args);
}
console.error(`method ${method} not found`);
return null;
}
function createErrorHandler(app) {
return function errorHandler(err, instance2, _info) {
if (!instance2) {
......@@ -15041,6 +15049,7 @@ function initApp$1(app) {
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
globalProperties.$callMethod = $callMethod;
}
{
invokeCreateVueAppHook(app);
......
......@@ -7300,6 +7300,14 @@ function applyOptions(options, instance, publicThis) {
function set(target, key, val) {
return target[key] = val;
}
function $callMethod(method, ...args) {
const fn = this[method];
if (fn) {
return fn(...args);
}
console.error(`method ${method} not found`);
return null;
}
function createErrorHandler(app) {
return function errorHandler(err, instance, _info) {
if (!instance) {
......@@ -7408,6 +7416,7 @@ function initApp$1(app) {
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
globalProperties.$callMethod = $callMethod;
}
{
uniShared.invokeCreateVueAppHook(app);
......
......@@ -14933,6 +14933,14 @@ function applyOptions(options, instance2, publicThis) {
function set(target, key, val) {
return target[key] = val;
}
function $callMethod(method, ...args) {
const fn = this[method];
if (fn) {
return fn(...args);
}
console.error(`method ${method} not found`);
return null;
}
function createErrorHandler(app) {
return function errorHandler(err, instance2, _info) {
if (!instance2) {
......@@ -15041,6 +15049,7 @@ function initApp$1(app) {
{
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
globalProperties.$callMethod = $callMethod;
}
{
invokeCreateVueAppHook(app);
......
......@@ -5485,6 +5485,14 @@ function applyOptions(options, instance, publicThis) {
function set(target, key, val) {
return (target[key] = val);
}
function $callMethod(method, ...args) {
const fn = this[method];
if (fn) {
return fn(...args);
}
console.error(`method ${method} not found`);
return null;
}
function createErrorHandler(app) {
return function errorHandler(err, instance, _info) {
......@@ -5602,6 +5610,7 @@ function initApp(app) {
if (__VUE_OPTIONS_API__) {
globalProperties.$set = set;
globalProperties.$applyOptions = applyOptions;
globalProperties.$callMethod = $callMethod;
}
{
uni.invokeCreateVueAppHook(app);
......
import { ComponentPublicInstance } from 'vue'
export function set(target: any, key: string | number, val: unknown) {
return (target[key] = val)
}
export function $callMethod(
this: ComponentPublicInstance,
method: string,
...args: Array<any>
): any {
const fn = (this as any)[method]
if (fn) {
return fn(...args)
}
console.error(`method ${method} not found`)
return null
}
......@@ -6,7 +6,7 @@ import {
} from '@dcloudio/uni-shared'
import { applyOptions } from './componentOptions'
import { set } from './componentInstance'
import { $callMethod, set } from './componentInstance'
import { createErrorHandler, initOptionMergeStrategies } from './appConfig'
import { uniIdMixin } from './uni-id-mixin'
......@@ -27,6 +27,7 @@ export function initApp(app: App) {
if (__VUE_OPTIONS_API__) {
globalProperties.$set = set
globalProperties.$applyOptions = applyOptions
globalProperties.$callMethod = $callMethod
}
if (__PLATFORM__ === 'app' || __PLATFORM__ === 'h5') {
invokeCreateVueAppHook(app)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册