提交 09fdc64a 编写于 作者: 杜庆泉's avatar 杜庆泉

增加async 多个参数的示例

上级 b2458cd5
...@@ -13,7 +13,11 @@ ...@@ -13,7 +13,11 @@
<button @click="testUtsAsync">点击测试uts异步方法</button> <button @click="testUtsAsync">点击测试uts异步方法</button>
<view>测试return:{{ format(testUtsAsyncResult.return) }}</view> <view>测试return:{{ format(testUtsAsyncResult.return) }}</view>
<view>测试success:{{ format(testUtsAsyncResult.success) }}</view> <view>测试success:{{ format(testUtsAsyncResult.success) }}</view>
<view>测试complete:{{ format(testUtsAsyncResult.complete) }}</view> <view>测试complete:{{ format(testUtsAsyncResult.complete) }}</view>
<button @click="testUtsAsyncMulitParam">点击测试uts异步方法-多参数</button>
<view>测试return:{{ format(testUtsAsyncMulitParamResult.return) }}</view>
<view>测试success:{{ format(testUtsAsyncMulitParamResult.success) }}</view>
<view>测试complete:{{ format(testUtsAsyncMulitParamResult.complete) }}</view>
<button @click="testUtsClassConstructor">点击测试uts class构造函数</button> <button @click="testUtsClassConstructor">点击测试uts class构造函数</button>
<view>测试callback:{{ format(testUtsClassConstructorResult.callback) }}</view> <view>测试callback:{{ format(testUtsClassConstructorResult.callback) }}</view>
<button @click="testUtsClassStaticProp">点击测试uts class静态属性</button> <button @click="testUtsClassStaticProp">点击测试uts class静态属性</button>
...@@ -55,7 +59,8 @@ ...@@ -55,7 +59,8 @@
MAX, MAX,
testSync, testSync,
testSyncWithCallback, testSyncWithCallback,
testAsync, testAsync,
testAsyncParam3,
Test, Test,
request, request,
} from "../../uni_modules/uts-syntaxcase"; } from "../../uni_modules/uts-syntaxcase";
...@@ -77,6 +82,12 @@ ...@@ -77,6 +82,12 @@
success: null, success: null,
fail: null, fail: null,
complete: null, complete: null,
},
testUtsAsyncMulitParamResult: {
return: null,
success: null,
fail: null,
complete: null,
}, },
testUtsClassConstructorResult: { testUtsClassConstructorResult: {
callback: null callback: null
...@@ -124,7 +135,8 @@ ...@@ -124,7 +135,8 @@
testAll() { testAll() {
this.testUtsSync(); this.testUtsSync();
this.testUtsSyncWithCallback(); this.testUtsSyncWithCallback();
this.testUtsAsync(); this.testUtsAsync();
this.testUtsAsyncMulitParam()
this.testUtsClassConstructor(); this.testUtsClassConstructor();
this.testUtsClassStaticProp(); this.testUtsClassStaticProp();
this.testUtsClassStaticSyncWithCallback(); this.testUtsClassStaticSyncWithCallback();
...@@ -195,6 +207,31 @@ ...@@ -195,6 +207,31 @@
this.testUtsAsyncResult.return = true; this.testUtsAsyncResult.return = true;
} }
} catch (e) {} } catch (e) {}
},
async testUtsAsyncMulitParam() {
this.testUtsAsyncMulitParamResult.return = false;
this.testUtsAsyncMulitParamResult.success = false;
// testUtsAsyncResult.fail = false;
this.testUtsAsyncMulitParamResult.complete = false;
try {
const res = await testAsyncParam3(100,"hello",{
type: "success",
success: (res) => {
console.log("testUtsAsyncMulitParam.success.callback", res);
this.testUtsAsyncMulitParamResult.success = true;
},
fail: (res) => {
console.log("testUtsAsyncMulitParam.fail.callback", res);
},
complete: (res) => {
console.log("testUtsAsyncMulitParam.complete.callback", res);
this.testUtsAsyncMulitParamResult.complete = true;
},
});
if (res.name === "testUtsAsyncMulitParam") {
this.testUtsAsyncMulitParamResult.return = true;
}
} catch (e) {}
}, },
testUtsClassConstructor() { testUtsClassConstructor() {
this.testUtsClassConstructorResult.callback = false this.testUtsClassConstructorResult.callback = false
......
...@@ -95,7 +95,25 @@ export async function testAsync(opts : AsyncOptions) : Promise<SyntaxResult> { ...@@ -95,7 +95,25 @@ export async function testAsync(opts : AsyncOptions) : Promise<SyntaxResult> {
} }
return await testAwaitPromise(res); return await testAwaitPromise(res);
// return { name: "testAsync" }; // return { name: "testAsync" };
} }
export async function testAsyncParam3(id:number,name:string,opts : AsyncOptions) : Promise<SyntaxResult> {
console.log("id",id,"name",name)
if (opts.type == "success") {
opts.success("success");
} else {
opts.fail("fail");
}
opts.complete("complete");
const res : SyntaxResult = {
name: "testUtsAsyncMulitParam"
}
return await testAwaitPromise(res);
// return { name: "testAsync" };
}
export type TestOptions = { export type TestOptions = {
name : string; name : string;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册