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

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

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