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

fix(mp): mp-alipay map 事件转换

上级 f5dae4e6
......@@ -17,7 +17,8 @@ import {
triggerEvent,
createObserver,
isComponent2,
initChildVues
initChildVues,
initSpecialEvents
} from './util'
function initVm (VueComponent) {
......@@ -46,23 +47,23 @@ function initVm (VueComponent) {
// 触发首次 setData
this.$vm.$mount()
} else {
} else {
// 处理父子关系
initRelation.call(this, {
vuePid: this._$vuePid,
vueOptions: options,
VueComponent,
mpInstance: this
})
})
if (options.parent) { // 父组件已经初始化,直接初始化子,否则放到父组件的 didMount 中处理
if (options.parent) { // 父组件已经初始化,直接初始化子,否则放到父组件的 didMount 中处理
// 初始化 vue 实例
this.$vm = new VueComponent(options)
this.$vm = new VueComponent(options)
handleRef.call(options.parent.$scope, this)
// 触发首次 setData
this.$vm.$mount()
initChildVues(this)
this.$vm.$mount()
initChildVues(this)
this.$vm._isMounted = true
this.$vm.__call_hook('mounted')
......@@ -118,8 +119,7 @@ export default function parseComponent (vueComponentOptions) {
componentOptions.didUpdate = createObserver(true)
}
if (vueOptions.methods && vueOptions.methods.formReset) {
componentOptions.methods.formReset = vueOptions.methods.formReset
}
initSpecialEvents(componentOptions.methods, vueOptions.methods)
return componentOptions
}
......@@ -12,8 +12,9 @@ import {
import {
handleRef,
handleLink,
initBehavior,
initChildVues
initBehavior,
initChildVues,
initSpecialEvents
} from './util'
const hooks = [
......@@ -53,7 +54,7 @@ export default function parsePage (vuePageOptions) {
this.$vm.__call_hook('onLoad', args)
},
onReady () {
initChildVues(this)
initChildVues(this)
this.$vm._isMounted = true
this.$vm.__call_hook('mounted')
this.$vm.__call_hook('onReady')
......@@ -67,11 +68,9 @@ export default function parsePage (vuePageOptions) {
__l: handleLink
}
initHooks(pageOptions, hooks)
if (vueOptions.methods && vueOptions.methods.formReset) {
pageOptions.formReset = vueOptions.methods.formReset
}
initHooks(pageOptions, hooks)
initSpecialEvents(pageOptions.methods, vueOptions.methods)
return pageOptions
}
......@@ -42,6 +42,25 @@ export function initRelation (detail) {
this.props.onVueInit(detail)
}
const SPECIAL_EVENTS = [
'formReset',
'markerTap',
'calloutTap',
'controlTap',
'regionChange'
]
export function initSpecialEvents (mpMethods, vueMethods) {
if (!vueMethods) {
return
}
SPECIAL_EVENTS.forEach((name) => {
if (vueMethods[name]) {
mpMethods[name] = vueMethods[name]
}
})
}
export function initChildVues (mpInstance) {
// 此时需保证当前 mpInstance 已经存在 $vm
if (!mpInstance.$vm) {
......@@ -52,7 +71,7 @@ export function initChildVues (mpInstance) {
vueOptions,
VueComponent,
mpInstance: childMPInstance
}) => {
}) => {
// 父子关系
handleBaseLink.call(mpInstance, {
detail: {
......@@ -65,9 +84,9 @@ export function initChildVues (mpInstance) {
handleRef.call(vueOptions.parent.$scope, childMPInstance)
childMPInstance.$vm.$mount()
initChildVues(childMPInstance)
childMPInstance.$vm.$mount()
initChildVues(childMPInstance)
childMPInstance.$vm._isMounted = true
childMPInstance.$vm.__call_hook('mounted')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册