diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 367d31c7aada012d604772bcf671382542a55e14..7b8420eddef112f79efbfcf4d0720b3001f80fc4 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -214,8 +214,12 @@ function wrapper (methodName, method) { } arg1 = processArgs(methodName, arg1, options.args, options.returnValue); - - const returnValue = wx[options.name || methodName](arg1, arg2); + + const args = [arg1]; + if (typeof arg2 !== 'undefined') { + args.push(arg2); + } + const returnValue = wx[options.name || methodName].apply(wx, args); if (isSyncApi(methodName)) { // 同步 api return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName)) } @@ -757,7 +761,15 @@ function handleEvent (event) { eventsArray.forEach(eventArray => { const methodName = eventArray[0]; if (methodName) { - const handler = this.$vm[methodName]; + let handlerCtx = this.$vm; + if ( + handlerCtx.$options.generic && + handlerCtx.$parent && + handlerCtx.$parent.$parent + ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = handlerCtx.$parent.$parent; + } + const handler = handlerCtx[methodName]; if (!isFn(handler)) { throw new Error(` _vm.${methodName} is not a function`) } @@ -767,7 +779,7 @@ function handleEvent (event) { } handler.once = true; } - handler.apply(this.$vm, processEventArgs( + handler.apply(handlerCtx, processEventArgs( this.$vm, event, eventArray[1], @@ -1101,7 +1113,8 @@ todos.forEach(todoApi => { }); canIUses.forEach(canIUseApi => { - const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi; + const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name + : canIUseApi; if (!wx.canIUse(apiName)) { protocols[canIUseApi] = false; } @@ -1117,7 +1130,7 @@ if (typeof Proxy !== 'undefined') { } if (api[name]) { return promisify(name, api[name]) - } + } if (!hasOwn(wx, name) && !hasOwn(protocols, name)) { return } @@ -1138,6 +1151,10 @@ if (typeof Proxy !== 'undefined') { }); } +wx.createApp = createApp; +wx.createPage = createPage; +wx.createComponent = createComponent; + var uni$1 = uni; export default uni$1; diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index 3fef785b7e9e86f04ab5d9a6e554ee98f24508eb..fc9ca72f98cc0c0fb5e8ab70df82fc9e1f3e043d 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-app-plus", - "version": "0.0.235", + "version": "0.0.236", "description": "uni-app app-plus", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js index b5298dab1f8562d5c48aa936ec8684a1de57e28c..1d32ea062456454caafb6517472144032a947d35 100644 --- a/packages/uni-mp-alipay/dist/index.js +++ b/packages/uni-mp-alipay/dist/index.js @@ -580,8 +580,12 @@ function wrapper (methodName, method) { } arg1 = processArgs(methodName, arg1, options.args, options.returnValue); - - const returnValue = my[options.name || methodName](arg1, arg2); + + const args = [arg1]; + if (typeof arg2 !== 'undefined') { + args.push(arg2); + } + const returnValue = my[options.name || methodName].apply(my, args); if (isSyncApi(methodName)) { // 同步 api return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName)) } @@ -1067,7 +1071,15 @@ function handleEvent (event) { eventsArray.forEach(eventArray => { const methodName = eventArray[0]; if (methodName) { - const handler = this.$vm[methodName]; + let handlerCtx = this.$vm; + if ( + handlerCtx.$options.generic && + handlerCtx.$parent && + handlerCtx.$parent.$parent + ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = handlerCtx.$parent.$parent; + } + const handler = handlerCtx[methodName]; if (!isFn(handler)) { throw new Error(` _vm.${methodName} is not a function`) } @@ -1077,7 +1089,7 @@ function handleEvent (event) { } handler.once = true; } - handler.apply(this.$vm, processEventArgs( + handler.apply(handlerCtx, processEventArgs( this.$vm, event, eventArray[1], @@ -1464,7 +1476,11 @@ function parsePage (vuePageOptions) { __l: handleLink$1 }; - initHooks(pageOptions, hooks$1); + initHooks(pageOptions, hooks$1); + + if (vueOptions.methods && vueOptions.methods.formReset) { + pageOptions.formReset = vueOptions.methods.formReset; + } return pageOptions } @@ -1590,7 +1606,8 @@ todos.forEach(todoApi => { }); canIUses.forEach(canIUseApi => { - const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi; + const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name + : canIUseApi; if (!my.canIUse(apiName)) { protocols[canIUseApi] = false; } @@ -1606,14 +1623,14 @@ if (typeof Proxy !== 'undefined') { } if (api[name]) { return promisify(name, api[name]) - } - { - if (extraApi[name]) { - return promisify(name, extraApi[name]) - } - if (todoApis[name]) { - return promisify(name, todoApis[name]) - } + } + { + if (extraApi[name]) { + return promisify(name, extraApi[name]) + } + if (todoApis[name]) { + return promisify(name, todoApis[name]) + } } if (!hasOwn(my, name) && !hasOwn(protocols, name)) { return @@ -1624,13 +1641,13 @@ if (typeof Proxy !== 'undefined') { } else { uni.upx2px = upx2px; - { - Object.keys(todoApis).forEach(name => { - uni[name] = promisify(name, todoApis[name]); - }); - Object.keys(extraApi).forEach(name => { - uni[name] = promisify(name, todoApis[name]); - }); + { + Object.keys(todoApis).forEach(name => { + uni[name] = promisify(name, todoApis[name]); + }); + Object.keys(extraApi).forEach(name => { + uni[name] = promisify(name, todoApis[name]); + }); } Object.keys(api).forEach(name => { @@ -1644,6 +1661,10 @@ if (typeof Proxy !== 'undefined') { }); } +my.createApp = createApp; +my.createPage = createPage; +my.createComponent = createComponent; + var uni$1 = uni; export default uni$1; diff --git a/packages/uni-mp-alipay/package.json b/packages/uni-mp-alipay/package.json index df3f736d7510ffa0f9f5be48dbf31cfbec1475f4..4a79e8e32adcc4aae27fa77f746409655393afc8 100644 --- a/packages/uni-mp-alipay/package.json +++ b/packages/uni-mp-alipay/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-alipay", - "version": "0.0.805", + "version": "0.0.806", "description": "uni-app mp-alipay", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index 3e99ebb3ec8cb6f9e5c895f4a32186b657efeadd..fc1bd7b909e15266d54320c17f0bc0f9c00eea0e 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -337,8 +337,12 @@ function wrapper (methodName, method) { } arg1 = processArgs(methodName, arg1, options.args, options.returnValue); - - const returnValue = swan[options.name || methodName](arg1, arg2); + + const args = [arg1]; + if (typeof arg2 !== 'undefined') { + args.push(arg2); + } + const returnValue = swan[options.name || methodName].apply(swan, args); if (isSyncApi(methodName)) { // 同步 api return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName)) } @@ -884,7 +888,15 @@ function handleEvent (event) { eventsArray.forEach(eventArray => { const methodName = eventArray[0]; if (methodName) { - const handler = this.$vm[methodName]; + let handlerCtx = this.$vm; + if ( + handlerCtx.$options.generic && + handlerCtx.$parent && + handlerCtx.$parent.$parent + ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = handlerCtx.$parent.$parent; + } + const handler = handlerCtx[methodName]; if (!isFn(handler)) { throw new Error(` _vm.${methodName} is not a function`) } @@ -894,7 +906,7 @@ function handleEvent (event) { } handler.once = true; } - handler.apply(this.$vm, processEventArgs( + handler.apply(handlerCtx, processEventArgs( this.$vm, event, eventArray[1], @@ -1237,7 +1249,8 @@ todos.forEach(todoApi => { }); canIUses.forEach(canIUseApi => { - const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi; + const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name + : canIUseApi; if (!swan.canIUse(apiName)) { protocols[canIUseApi] = false; } @@ -1253,14 +1266,14 @@ if (typeof Proxy !== 'undefined') { } if (api[name]) { return promisify(name, api[name]) - } - { - if (extraApi[name]) { - return promisify(name, extraApi[name]) - } - if (todoApis[name]) { - return promisify(name, todoApis[name]) - } + } + { + if (extraApi[name]) { + return promisify(name, extraApi[name]) + } + if (todoApis[name]) { + return promisify(name, todoApis[name]) + } } if (!hasOwn(swan, name) && !hasOwn(protocols, name)) { return @@ -1271,13 +1284,13 @@ if (typeof Proxy !== 'undefined') { } else { uni.upx2px = upx2px; - { - Object.keys(todoApis).forEach(name => { - uni[name] = promisify(name, todoApis[name]); - }); - Object.keys(extraApi).forEach(name => { - uni[name] = promisify(name, todoApis[name]); - }); + { + Object.keys(todoApis).forEach(name => { + uni[name] = promisify(name, todoApis[name]); + }); + Object.keys(extraApi).forEach(name => { + uni[name] = promisify(name, todoApis[name]); + }); } Object.keys(api).forEach(name => { @@ -1291,6 +1304,10 @@ if (typeof Proxy !== 'undefined') { }); } +swan.createApp = createApp; +swan.createPage = createPage; +swan.createComponent = createComponent; + var uni$1 = uni; export default uni$1; diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index 91a32dab3cd336c272ee381807f77c20373c1229..286abe454d67c53616ace7fa6579b5759abc529c 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-baidu", - "version": "0.0.833", + "version": "0.0.834", "description": "uni-app mp-baidu", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 8d1f8a56ea02a4ce56419feb832df887797343f9..361594350975607e5491794d6f983901352f5f68 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -398,8 +398,12 @@ function wrapper (methodName, method) { } arg1 = processArgs(methodName, arg1, options.args, options.returnValue); - - const returnValue = tt[options.name || methodName](arg1, arg2); + + const args = [arg1]; + if (typeof arg2 !== 'undefined') { + args.push(arg2); + } + const returnValue = tt[options.name || methodName].apply(tt, args); if (isSyncApi(methodName)) { // 同步 api return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName)) } @@ -903,7 +907,15 @@ function handleEvent (event) { eventsArray.forEach(eventArray => { const methodName = eventArray[0]; if (methodName) { - const handler = this.$vm[methodName]; + let handlerCtx = this.$vm; + if ( + handlerCtx.$options.generic && + handlerCtx.$parent && + handlerCtx.$parent.$parent + ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = handlerCtx.$parent.$parent; + } + const handler = handlerCtx[methodName]; if (!isFn(handler)) { throw new Error(` _vm.${methodName} is not a function`) } @@ -913,7 +925,7 @@ function handleEvent (event) { } handler.once = true; } - handler.apply(this.$vm, processEventArgs( + handler.apply(handlerCtx, processEventArgs( this.$vm, event, eventArray[1], @@ -1312,7 +1324,8 @@ todos.forEach(todoApi => { }); canIUses.forEach(canIUseApi => { - const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi; + const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name + : canIUseApi; if (!tt.canIUse(apiName)) { protocols[canIUseApi] = false; } @@ -1328,14 +1341,14 @@ if (typeof Proxy !== 'undefined') { } if (api[name]) { return promisify(name, api[name]) - } - { - if (extraApi[name]) { - return promisify(name, extraApi[name]) - } - if (todoApis[name]) { - return promisify(name, todoApis[name]) - } + } + { + if (extraApi[name]) { + return promisify(name, extraApi[name]) + } + if (todoApis[name]) { + return promisify(name, todoApis[name]) + } } if (!hasOwn(tt, name) && !hasOwn(protocols, name)) { return @@ -1346,13 +1359,13 @@ if (typeof Proxy !== 'undefined') { } else { uni.upx2px = upx2px; - { - Object.keys(todoApis).forEach(name => { - uni[name] = promisify(name, todoApis[name]); - }); - Object.keys(extraApi).forEach(name => { - uni[name] = promisify(name, todoApis[name]); - }); + { + Object.keys(todoApis).forEach(name => { + uni[name] = promisify(name, todoApis[name]); + }); + Object.keys(extraApi).forEach(name => { + uni[name] = promisify(name, todoApis[name]); + }); } Object.keys(api).forEach(name => { @@ -1366,6 +1379,10 @@ if (typeof Proxy !== 'undefined') { }); } +tt.createApp = createApp; +tt.createPage = createPage; +tt.createComponent = createComponent; + var uni$1 = uni; export default uni$1; diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index dc28b1c556cba283f076f5e7ab13f2d21074d802..e87821d5ab13896683233004510d31e52a7839f9 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-toutiao", - "version": "0.0.333", + "version": "0.0.334", "description": "uni-app mp-toutiao", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index a5b98037c9929e4870cfb6bcd75df189bbf0284d..0e91e57af0a8f46e5d4a6378adbf625a55190ed6 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -250,8 +250,12 @@ function wrapper (methodName, method) { } arg1 = processArgs(methodName, arg1, options.args, options.returnValue); - - const returnValue = wx[options.name || methodName](arg1, arg2); + + const args = [arg1]; + if (typeof arg2 !== 'undefined') { + args.push(arg2); + } + const returnValue = wx[options.name || methodName].apply(wx, args); if (isSyncApi(methodName)) { // 同步 api return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName)) } @@ -760,7 +764,15 @@ function handleEvent (event) { eventsArray.forEach(eventArray => { const methodName = eventArray[0]; if (methodName) { - const handler = this.$vm[methodName]; + let handlerCtx = this.$vm; + if ( + handlerCtx.$options.generic && + handlerCtx.$parent && + handlerCtx.$parent.$parent + ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = handlerCtx.$parent.$parent; + } + const handler = handlerCtx[methodName]; if (!isFn(handler)) { throw new Error(` _vm.${methodName} is not a function`) } @@ -770,7 +782,7 @@ function handleEvent (event) { } handler.once = true; } - handler.apply(this.$vm, processEventArgs( + handler.apply(handlerCtx, processEventArgs( this.$vm, event, eventArray[1], @@ -1072,7 +1084,8 @@ todos.forEach(todoApi => { }); canIUses.forEach(canIUseApi => { - const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi; + const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name + : canIUseApi; if (!wx.canIUse(apiName)) { protocols[canIUseApi] = false; } @@ -1088,14 +1101,14 @@ if (typeof Proxy !== 'undefined') { } if (api[name]) { return promisify(name, api[name]) - } - { - if (extraApi[name]) { - return promisify(name, extraApi[name]) - } - if (todoApis[name]) { - return promisify(name, todoApis[name]) - } + } + { + if (extraApi[name]) { + return promisify(name, extraApi[name]) + } + if (todoApis[name]) { + return promisify(name, todoApis[name]) + } } if (!hasOwn(wx, name) && !hasOwn(protocols, name)) { return @@ -1106,13 +1119,13 @@ if (typeof Proxy !== 'undefined') { } else { uni.upx2px = upx2px; - { - Object.keys(todoApis).forEach(name => { - uni[name] = promisify(name, todoApis[name]); - }); - Object.keys(extraApi).forEach(name => { - uni[name] = promisify(name, todoApis[name]); - }); + { + Object.keys(todoApis).forEach(name => { + uni[name] = promisify(name, todoApis[name]); + }); + Object.keys(extraApi).forEach(name => { + uni[name] = promisify(name, todoApis[name]); + }); } Object.keys(api).forEach(name => { @@ -1126,6 +1139,10 @@ if (typeof Proxy !== 'undefined') { }); } +wx.createApp = createApp; +wx.createPage = createPage; +wx.createComponent = createComponent; + var uni$1 = uni; export default uni$1; diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index 091a2ed413263358c91823c7f0f1fa79ed2807b9..4daaf91029397429b783e929316ae04e129ed40c 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.955", + "version": "0.0.956", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/runtime/index.js b/src/core/runtime/index.js index 9e7304fc69aff1cff7f7fc667f6e4af649622317..65b86341ea8e822769a6fede95f70b49fea85ec8 100644 --- a/src/core/runtime/index.js +++ b/src/core/runtime/index.js @@ -13,19 +13,28 @@ import { import wrapper from './wrapper' import todoApi from './todo' - -import * as extraApi from './extra' + +import * as extraApi from './extra' import * as api from 'uni-platform/service/api/index.js' -import { protocols, todos, canIUses } from 'uni-platform/service/api/protocols' +import { + protocols, + todos, + canIUses +} from 'uni-platform/service/api/protocols' + +import createApp from './wrapper/create-app' +import createPage from './wrapper/create-page' +import createComponent from './wrapper/create-component' todos.forEach(todoApi => { protocols[todoApi] = false }) canIUses.forEach(canIUseApi => { - const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name : canIUseApi + const apiName = protocols[canIUseApi] && protocols[canIUseApi].name ? protocols[canIUseApi].name + : canIUseApi if (!__GLOBAL__.canIUse(apiName)) { protocols[canIUseApi] = false } @@ -41,14 +50,14 @@ if (typeof Proxy !== 'undefined') { } if (api[name]) { return promisify(name, api[name]) - } - if (__PLATFORM__ !== 'app-plus') { - if (extraApi[name]) { - return promisify(name, extraApi[name]) - } - if (todoApi[name]) { - return promisify(name, todoApi[name]) - } + } + if (__PLATFORM__ !== 'app-plus') { + if (extraApi[name]) { + return promisify(name, extraApi[name]) + } + if (todoApi[name]) { + return promisify(name, todoApi[name]) + } } if (!hasOwn(__GLOBAL__, name) && !hasOwn(protocols, name)) { return @@ -59,13 +68,13 @@ if (typeof Proxy !== 'undefined') { } else { uni.upx2px = upx2px - if (__PLATFORM__ !== 'app-plus') { - Object.keys(todoApi).forEach(name => { - uni[name] = promisify(name, todoApi[name]) - }) - Object.keys(extraApi).forEach(name => { - uni[name] = promisify(name, todoApi[name]) - }) + if (__PLATFORM__ !== 'app-plus') { + Object.keys(todoApi).forEach(name => { + uni[name] = promisify(name, todoApi[name]) + }) + Object.keys(extraApi).forEach(name => { + uni[name] = promisify(name, todoApi[name]) + }) } Object.keys(api).forEach(name => { @@ -79,8 +88,14 @@ if (typeof Proxy !== 'undefined') { }) } -export * from './wrapper/create-app' -export * from './wrapper/create-page' -export * from './wrapper/create-component' +__GLOBAL__.createApp = createApp +__GLOBAL__.createPage = createPage +__GLOBAL__.createComponent = createComponent + +export { + createApp, + createPage, + createComponent +} export default uni diff --git a/src/core/runtime/wrapper.js b/src/core/runtime/wrapper.js index f04beb6d6005c1eacacc0b3bdf254b2977859905..93acb5c30d9830b34d1082f474b0e3805faa14aa 100644 --- a/src/core/runtime/wrapper.js +++ b/src/core/runtime/wrapper.js @@ -76,8 +76,12 @@ export default function wrapper (methodName, method) { } arg1 = processArgs(methodName, arg1, options.args, options.returnValue) - - const returnValue = __GLOBAL__[options.name || methodName](arg1, arg2) + + const args = [arg1] + if (typeof arg2 !== 'undefined') { + args.push(arg2) + } + const returnValue = __GLOBAL__[options.name || methodName].apply(__GLOBAL__, args) if (isSyncApi(methodName)) { // 同步 api return processReturnValue(methodName, returnValue, options.returnValue, isContextApi(methodName)) } diff --git a/src/core/runtime/wrapper/create-app.js b/src/core/runtime/wrapper/create-app.js index 8775a33f8cc5c62e54e74116de490bad5bcb289b..f7bf662731fde1acb110be1b8bc869d3e486e57c 100644 --- a/src/core/runtime/wrapper/create-app.js +++ b/src/core/runtime/wrapper/create-app.js @@ -2,7 +2,7 @@ import 'uni-platform/runtime/index' import parseApp from 'uni-platform/runtime/wrapper/app-parser' -export function createApp (vm) { +export default function createApp (vm) { App(parseApp(vm)) return vm } diff --git a/src/core/runtime/wrapper/create-component.js b/src/core/runtime/wrapper/create-component.js index 6d979a2fc37697aee8dd0eebb792522c0c698d8c..a8a274b748c27c93b2fa77b8cb8494f4771fde47 100644 --- a/src/core/runtime/wrapper/create-component.js +++ b/src/core/runtime/wrapper/create-component.js @@ -1,6 +1,6 @@ import parseComponent from 'uni-platform/runtime/wrapper/component-parser' -export function createComponent (vueOptions) { +export default function createComponent (vueOptions) { if (__PLATFORM__ === 'mp-alipay') { return my.createComponent(parseComponent(vueOptions)) } else { diff --git a/src/core/runtime/wrapper/create-page.js b/src/core/runtime/wrapper/create-page.js index 0314e040e3cf1e0b719287c8dde2f3af5a8e513e..94c69c1fde60a4db643b59ea67ad2324b2d9b3c8 100644 --- a/src/core/runtime/wrapper/create-page.js +++ b/src/core/runtime/wrapper/create-page.js @@ -1,6 +1,6 @@ import parsePage from 'uni-platform/runtime/wrapper/page-parser' -export function createPage (vuePageOptions) { +export default function createPage (vuePageOptions) { if (__PLATFORM__ === 'mp-alipay') { return Page(parsePage(vuePageOptions)) } else { diff --git a/src/core/runtime/wrapper/util.js b/src/core/runtime/wrapper/util.js index be19c912707417eb9a5d37ecfae56e0503e5d94e..fea82a82565260090d69685ea9b72c3f53f8cf88 100644 --- a/src/core/runtime/wrapper/util.js +++ b/src/core/runtime/wrapper/util.js @@ -418,7 +418,15 @@ export function handleEvent (event) { eventsArray.forEach(eventArray => { const methodName = eventArray[0] if (methodName) { - const handler = this.$vm[methodName] + let handlerCtx = this.$vm + if ( + handlerCtx.$options.generic && + handlerCtx.$parent && + handlerCtx.$parent.$parent + ) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots + handlerCtx = handlerCtx.$parent.$parent + } + const handler = handlerCtx[methodName] if (!isFn(handler)) { throw new Error(` _vm.${methodName} is not a function`) } @@ -428,7 +436,7 @@ export function handleEvent (event) { } handler.once = true } - handler.apply(this.$vm, processEventArgs( + handler.apply(handlerCtx, processEventArgs( this.$vm, event, eventArray[1], diff --git a/src/platforms/mp-alipay/runtime/wrapper/page-parser.js b/src/platforms/mp-alipay/runtime/wrapper/page-parser.js index 5cc79a6928f3a4c6c2d68e2255a77b0ca43027df..020a6a5328fd0c234aac01fcd58e2f34d1255c7b 100644 --- a/src/platforms/mp-alipay/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-alipay/runtime/wrapper/page-parser.js @@ -67,7 +67,11 @@ export default function parsePage (vuePageOptions) { __l: handleLink } - initHooks(pageOptions, hooks) + initHooks(pageOptions, hooks) + + if (vueOptions.methods && vueOptions.methods.formReset) { + pageOptions.formReset = vueOptions.methods.formReset + } return pageOptions }