Showing
2 changed files
with
11 additions
and
1 deletions
@@ -249,7 +249,9 @@ const yoho = { | @@ -249,7 +249,9 @@ const yoho = { | ||
249 | * @param callback 回调 | 249 | * @param callback 回调 |
250 | */ | 250 | */ |
251 | addNativeMethod(name, callback) { | 251 | addNativeMethod(name, callback) { |
252 | - window.yohoInterface[name] = callback; | 252 | + if (window.yohoInterface) { |
253 | + window.yohoInterface[name] = callback; | ||
254 | + } | ||
253 | } | 255 | } |
254 | }; | 256 | }; |
255 | 257 |
@@ -29,6 +29,14 @@ | @@ -29,6 +29,14 @@ | ||
29 | return { | 29 | return { |
30 | yoho | 30 | yoho |
31 | }; | 31 | }; |
32 | + }, | ||
33 | + created() { | ||
34 | + yoho.addNativeMethod('headerRightTopBtn', function(data) { | ||
35 | + alert('app 调用 H5 成功!'); | ||
36 | + if (data) { | ||
37 | + alert('传递的信息是:' + data); | ||
38 | + } | ||
39 | + }); | ||
32 | } | 40 | } |
33 | }; | 41 | }; |
34 | </script> | 42 | </script> |
-
Please register or login to post a comment