Files
aistream-test/UTS 插件工程/pages/SyntaxCase/MixNativeCode.uvue
T
2025-11-27 20:48:18 +08:00

63 lines
1.9 KiB
Plaintext

<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-btn-v uni-common-mt">
// #ifdef APP-ANDROID && UNI-APP-X
<button @tap="callKotlinMethodGetInfoTest">调用kotlin方法</button>
<button @tap="callJavaMethodGetInfoTest">调用java方法(需自定义基座)</button>
<view style="height: 10px;width: 100%;"></view>
<button @tap="kotlinMemListenTest">kotlin监听内存并持续回调UTS</button>
<button @tap="kotlinStopMemListenTest">停止监听</button>
<text>{{memInfo}}</text>
// #endif
</view>
</view>
</template>
<script>
// #ifdef APP-ANDROID && UNI-APP-X
import { callKotlinMethodGetInfo, callJavaMethodGetInfo,callKotlinCallbackUTS,callKotlinStopCallbackUTS} from "../../uni_modules/uts-syntaxcase";
// #endif
export default {
data() {
return {
title: 'UTS混编示例',
memInfo:''
}
},
methods: {
// #ifdef APP-ANDROID && UNI-APP-X
callKotlinMethodGetInfoTest: function () {
let phoneInfo = callKotlinMethodGetInfo();
uni.showToast({
title:phoneInfo
})
},
callJavaMethodGetInfoTest: function () {
let javaInfo = callJavaMethodGetInfo();
uni.showToast({
title:javaInfo
})
},
kotlinMemListenTest: function () {
callKotlinCallbackUTS(function(ret:string){
this.memInfo = ret
})
},
kotlinStopMemListenTest:function () {
callKotlinStopCallbackUTS()
},
// #endif
}
}
</script>
<style>
</style>