首次上传
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
<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>
|
||||
Reference in New Issue
Block a user