|
|
<template> <div> <button type="primary" @click="testAsyncFunc">testAsyncFunc</button> <button type="primary" @click="testSyncFunc">testSyncFunc</button> <button type="primary" @click="gotoNativePage">跳转原生Activity</button> <button type="primary" @click="testAsyncFunc2">testAsyncFunc2</button> <button type="primary" @click="testSyncFunc2">testSyncFunc2</button> <button type="primary" @click="testFun1">zmt-testFun1</button> <button type="primary" @click="testFun2">zmt-testFun2</button> </div> </template>
<script> // 获取 module var zmtModule = uni.requireNativePlugin("Zmt-Module") var testModule = uni.requireNativePlugin("TestModule") var testModule2 = uni.requireNativePlugin("TestModule2") const modal = uni.requireNativePlugin('modal'); export default { onLoad() { plus.globalEvent.addEventListener('TestEvent', function(e){ modal.toast({ message: "TestEvent收到:"+e.msg, duration: 1.5 }); }); }, methods: { testFun1(){ // 调用异步方法 zmtModule.testAsyncFunc({ 'name': 'unimp', 'age': 1 }, (ret) => { modal.toast({ message: ret, duration: 1.5 }); }) }, testFun2(){ // 调用同步方法 var ret = zmtModule.testSyncFunc({ 'name': 'unimp', 'age': 1 }) modal.toast({ message: ret, duration: 1.5 }); }, testAsyncFunc() { // 调用异步方法 testModule.testAsyncFunc({ 'name': 'unimp', 'age': 1 }, (ret) => { modal.toast({ message: ret, duration: 1.5 }); }) }, testSyncFunc() { // 调用同步方法 var ret = testModule.testSyncFunc({ 'name': 'unimp', 'age': 1 }) modal.toast({ message: ret, duration: 1.5 }); }, testAsyncFunc2() { // 调用异步方法 testModule2.testAsyncFunc2({ 'name': 'unimp', 'age': 1 }, (ret) => { modal.toast({ message: ret, duration: 1.5 }); }) }, testSyncFunc2() { // 调用同步方法 var ret = testModule2.testSyncFunc2({ 'name': 'unimp', 'age': 1 }) modal.toast({ message: ret, duration: 1.5 }); }, gotoNativePage() { testModule.gotoNativePage(); } } } </script>
|