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

feat(mp-alipay): refactor map,form

上级 cac55db1
......@@ -1283,23 +1283,28 @@ function initRelation$1 (detail) {
this.props.onVueInit(detail);
}
const SPECIAL_EVENTS = [
'formReset',
'markerTap',
'calloutTap',
'controlTap',
'regionChange'
];
function initSpecialEvents (mpMethods, vueMethods) {
if (!vueMethods) {
function initSpecialMethods (mpInstance) {
if (!mpInstance.$vm) {
return
}
SPECIAL_EVENTS.forEach((name) => {
if (vueMethods[name]) {
mpMethods[name] = vueMethods[name];
}
});
let path = mpInstance.is || mpInstance.route;
if (!path) {
return
}
if (path.indexOf('/') === 0) {
path = path.substr(1);
}
const specialMethods = my.specialMethods && my.specialMethods[path];
if (specialMethods) {
specialMethods.forEach(method => {
if (isFn(mpInstance.$vm[method])) {
mpInstance[method] = function (event) {
// TODO normalizeEvent
mpInstance.$vm[method](event);
};
}
});
}
}
function initChildVues (mpInstance) {
......@@ -1323,6 +1328,8 @@ function initChildVues (mpInstance) {
childMPInstance.$vm = new VueComponent(vueOptions);
initSpecialMethods(childMPInstance);
handleRef.call(vueOptions.parent.$scope, childMPInstance);
childMPInstance.$vm.$mount();
......@@ -1473,6 +1480,8 @@ function parsePage (vuePageOptions) {
// 初始化 vue 实例
this.$vm = new VueComponent(options);
initSpecialMethods(this);
// 触发首次 setData
this.$vm.$mount();
......@@ -1497,8 +1506,6 @@ function parsePage (vuePageOptions) {
initHooks(pageOptions, hooks$1);
initSpecialEvents(pageOptions, vueOptions.methods);
return pageOptions
}
......@@ -1578,8 +1585,11 @@ function parseComponent (vueComponentOptions) {
mixins: initBehaviors(vueOptions, initBehavior$1),
data: initData(vueOptions, Vue.prototype),
props,
didMount () {
didMount () {
initVm.call(this, VueComponent);
initSpecialMethods(this);
if (isComponent2) {
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted');
......@@ -1606,8 +1616,6 @@ function parseComponent (vueComponentOptions) {
componentOptions.didUpdate = createObserver$1(true);
}
initSpecialEvents(componentOptions.methods, vueOptions.methods);
return componentOptions
}
......
{
"name": "@dcloudio/uni-mp-alipay",
"version": "0.0.807",
"version": "0.0.808",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"scripts": {
......
......@@ -18,7 +18,7 @@ import {
createObserver,
isComponent2,
initChildVues,
initSpecialEvents
initSpecialMethods
} from './util'
function initVm (VueComponent) {
......@@ -91,8 +91,11 @@ export default function parseComponent (vueComponentOptions) {
mixins: initBehaviors(vueOptions, initBehavior),
data: initData(vueOptions, Vue.prototype),
props,
didMount () {
didMount () {
initVm.call(this, VueComponent)
initSpecialMethods(this)
if (isComponent2) {
this.$vm._isMounted = true
this.$vm.__call_hook('mounted')
......@@ -119,7 +122,5 @@ export default function parseComponent (vueComponentOptions) {
componentOptions.didUpdate = createObserver(true)
}
initSpecialEvents(componentOptions.methods, vueOptions.methods)
return componentOptions
}
......@@ -14,7 +14,7 @@ import {
handleLink,
initBehavior,
initChildVues,
initSpecialEvents
initSpecialMethods
} from './util'
const hooks = [
......@@ -46,6 +46,8 @@ export default function parsePage (vuePageOptions) {
// 初始化 vue 实例
this.$vm = new VueComponent(options)
initSpecialMethods(this)
// 触发首次 setData
this.$vm.$mount()
......@@ -70,7 +72,5 @@ export default function parsePage (vuePageOptions) {
initHooks(pageOptions, hooks)
initSpecialEvents(pageOptions, vueOptions.methods)
return pageOptions
}
......@@ -42,23 +42,28 @@ export function initRelation (detail) {
this.props.onVueInit(detail)
}
const SPECIAL_EVENTS = [
'formReset',
'markerTap',
'calloutTap',
'controlTap',
'regionChange'
]
export function initSpecialEvents (mpMethods, vueMethods) {
if (!vueMethods) {
export function initSpecialMethods (mpInstance) {
if (!mpInstance.$vm) {
return
}
SPECIAL_EVENTS.forEach((name) => {
if (vueMethods[name]) {
mpMethods[name] = vueMethods[name]
}
})
let path = mpInstance.is || mpInstance.route
if (!path) {
return
}
if (path.indexOf('/') === 0) {
path = path.substr(1)
}
const specialMethods = my.specialMethods && my.specialMethods[path]
if (specialMethods) {
specialMethods.forEach(method => {
if (isFn(mpInstance.$vm[method])) {
mpInstance[method] = function (event) {
// TODO normalizeEvent
mpInstance.$vm[method](event)
}
}
})
}
}
export function initChildVues (mpInstance) {
......@@ -82,6 +87,8 @@ export function initChildVues (mpInstance) {
childMPInstance.$vm = new VueComponent(vueOptions)
initSpecialMethods(childMPInstance)
handleRef.call(vueOptions.parent.$scope, childMPInstance)
childMPInstance.$vm.$mount()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册