Skip to content

Commit ddb2115

Browse files
author
F-loat
committed
optimize: 代理函数增加返回值
1 parent ad27484 commit ddb2115

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/platforms/mp/compiler/codegen/convert/attrs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default {
5151
})
5252
} else if (key === 'v-html') {
5353
ast.tag = 'rich-text'
54-
attrs['nodes'] = '{{' + val + '}}'
54+
attrs['nodes'] = `{{${val}}}`
5555
} else if (key === 'v-show') {
5656
attrs['hidden'] = `{{!(${val})}}`
5757
} else if (/^v\-on\:/i.test(key)) {

src/platforms/mp/runtime/events.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,16 @@ export function handleProxyWithVue (e) {
9999
// https://developer.mozilla.org/zh-CN/docs/Web/API/Event
100100
if (handles.length) {
101101
const event = getWebEventByMP(e)
102+
if (handles.length === 1) {
103+
const result = handles[0](event)
104+
return result
105+
}
102106
handles.forEach(h => h(event))
103107
} else {
108+
// TODO, 在初始化时进行判断或直接使用 vue 本身的错误提示
104109
const { route } = rootVueVM.$mp.page
105110
console.group(new Date() + ' 事件警告')
106-
console.warn(`Do not have handler in current page: ${route}. Please make sure that handler has been defined in ${route}, or ${route} has been added into app.json`)
111+
console.warn(`Do not have handler in current page: ${route}. Please make sure that handler has been defined in ${route}, or not use handler with 'v-if'`)
107112
console.groupEnd()
108113
}
109114
}

src/platforms/mp/runtime/lifecycle.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function initMP (mpType, next) {
7070
},
7171

7272
handleProxy (e) {
73-
rootVueVM.$handleProxyWithVue(e)
73+
return rootVueVM.$handleProxyWithVue(e)
7474
},
7575

7676
// Do something initial when launch.
@@ -107,7 +107,7 @@ export function initMP (mpType, next) {
107107
},
108108
methods: {
109109
handleProxy (e) {
110-
rootVueVM.$handleProxyWithVue(e)
110+
return rootVueVM.$handleProxyWithVue(e)
111111
}
112112
},
113113
// mp lifecycle for vue
@@ -152,7 +152,7 @@ export function initMP (mpType, next) {
152152
},
153153

154154
handleProxy (e) {
155-
rootVueVM.$handleProxyWithVue(e)
155+
return rootVueVM.$handleProxyWithVue(e)
156156
},
157157

158158
// mp lifecycle for vue

0 commit comments

Comments
 (0)