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

118 lines
2.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view>
<page-head :title="title"></page-head>
<input class="uni-input" v-model="stringParam" />
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="testDoSthWithCallback">uts异步方法无参数</button>
<button type="primary" @tap="testDoSthWithString">uts异步方法字符串参数</button>
<button type="primary" @tap="testDoSthWithJSON">uts异步方法json参数</button>
<button type="primary" @tap="testCallback">多次回调示例2</button>
<button type="primary" @tap="testPluginDepend">uts插件依赖示例</button>
<button type="primary" @tap="testBuildinObject">内置对象语法测试</button>
</view>
</view>
</template>
<script>
import { callWithJSONParam, callWithStringParam, callWithoutParam,onCallback } from "../../uni_modules/uts-helloworld";
import { testb } from "@/uni_modules/uts-test-b";
export default {
data() {
return {
title: 'UTS入门示例',
stringParam:"hello world",
}
},
methods: {
/**
* 测试无参数调用
*/
testDoSthWithCallback: function () {
callWithoutParam(
()=>{
uni.showToast({
title:'成功调用uts插件uts-helloworld的callWithoutParam1',
icon:'none'
});
}
);
},
/**
* 测试字符串参数回调
*/
testDoSthWithString: function () {
callWithStringParam(
this.stringParam,
function(response){
uni.showToast({
title:'uts插件uts-helloworld的onCallback方法:'+response,
icon:'none'
});
},
);
},
/**
* 测试json参数回调
*/
testDoSthWithJSON: function () {
var inputObject = {
inputText:this.stringParam,
errCode:0,
complete: (res) => {
uni.showToast({
title: '嵌套回调结果:' + JSON.stringify(res),
icon: 'none'
});
}
}
callWithJSONParam({
input:inputObject,
success:function(response){
uni.showToast({
title:'执行结果:' + JSON.stringify(response),
icon:'none'
});
}
});
},
testCallback: function () {
onCallback(
function(response){
uni.showToast({
title:'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:'+response,
icon:'none'
});
},
);
},
/**
* 测试内置对象
*/
testBuildinObject: function() {
uni.navigateTo({
url: `/pages/index/basicTest`
})
},
/**
* 测试插件依赖
*/
testPluginDepend() {
testb()
}
}
}
</script>
<style>
</style>