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

116 lines
3.8 KiB
Plaintext

<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">多次回调示例1</button>
<button type="primary" @tap="testPluginDepend">uts插件依赖示例</button>
<button type="primary" @tap="testBuildinObject">内置对象语法测试</button>
</view>
</view>
</template>
<script>
import { callWithJSONParam, callWithStringParam, callWithoutParam, JsonParamOptions, inputJSON ,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的callWithoutParam',
icon: 'none'
});
}
);
},
/**
* 测试字符串参数回调
*/
testDoSthWithString: function () {
callWithStringParam(
this.stringParam,
function (response) {
uni.showToast({
title: 'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:' + response,
icon: 'none'
});
},
);
},
/**
* 测试json参数回调
*/
testDoSthWithJSON: function () {
const that = this
var inputObject : inputJSON = {
inputText: that.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'
});
}
} as JsonParamOptions);
},
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>