提交 0b467edf 编写于 作者: 杜庆泉's avatar 杜庆泉

增加多次回调示例 &部分测试示例报错

上级 8f90479d
......@@ -6,12 +6,13 @@
<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">多次回调示例</button>
<button type="primary" @tap="testBuildinObject">内置对象语法测试</button>
</view>
</view>
</template>
<script>
import { callWithJSONParam, callWithStringParam, callWithoutParam, JsonParamOptions, inputJSON } from "../../uni_modules/uts-helloworld";
import { callWithJSONParam, callWithStringParam, callWithoutParam, JsonParamOptions, inputJSON ,onCallback} from "../../uni_modules/uts-helloworld";
export default {
data() {
......@@ -72,6 +73,17 @@
}
} as JsonParamOptions);
},
testCallback: function () {
onCallback(
function(response){
uni.showToast({
title:'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:'+response,
icon:'none'
});
},
);
},
/**
* 测试内置对象
*/
......
......@@ -6,12 +6,13 @@
<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">多次回调示例</button>
<button type="primary" @tap="testBuildinObject">内置对象语法测试</button>
</view>
</view>
</template>
<script>
import { callWithJSONParam, callWithStringParam, callWithoutParam } from "../../uni_modules/uts-helloworld";
import { callWithJSONParam, callWithStringParam, callWithoutParam,onCallback } from "../../uni_modules/uts-helloworld";
export default {
data() {
......@@ -46,7 +47,7 @@
this.stringParam,
function(response){
uni.showToast({
title:'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串'+response,
title:'uts插件uts-helloworld的onCallback方法'+response,
icon:'none'
});
},
......@@ -71,6 +72,18 @@
}
});
},
testCallback: function () {
onCallback(
function(response){
uni.showToast({
title:'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:'+response,
icon:'none'
});
},
);
},
/**
* 测试内置对象
*/
......
......@@ -42,4 +42,23 @@ export function callWithJSONParam(opts: JsonParamOptions) {
}
/**
* 导出多次回调UTS函数
* @param opts
*/
export function onCallback(callback: (sth:string) => void) {
/**
* 模拟多次回调
*/
let count = 1
let taskId = -1
taskId = setInterval(function() {
callback("第" + count + "次回调")
count++;
console.log("count",count)
if(count > 3){
clearInterval(taskId)
}
}, 500);
}
......@@ -63,18 +63,18 @@ export function testMath(): Result {
expect(Math.acos(-1)).toEqual(3.141592653589793);
expect(Math.acos(0)).toEqual(1.5707963267948966);
// 解决精度问题
expect(Math.acos(1)).toEqual(0.0);
expect(Math.acos(1)).toEqual(0);
})
test('acosh', () => {
// 解决精度问题
expect(Math.acosh(1)).toEqual(0.0);
expect(Math.acosh(1)).toEqual(0);
expectNumber(Math.acosh(2)).toEqualDouble(1.3169578969248166);
expectNumber(Math.acosh(2.5)).toEqualDouble(1.566799236972411);
})
test('asin', () => {
expect(Math.asin(-1)).toEqual(-1.5707963267948966);
// 解决精度问题
expect(Math.asin(0)).toEqual(0.0);
expect(Math.asin(0)).toEqual(0);
// expect(Math.asin(0.5)).toEqual(0.5235987755982989);
expect(Math.asin(1)).toEqual(1.5707963267948966);
})
......@@ -87,16 +87,16 @@ export function testMath(): Result {
test('atan', () => {
expect(Math.atan(1)).toEqual(0.7853981633974483);
// 解决精度问题
expect(Math.atan(0)).toEqual(0.0);
expect(Math.atan(0)).toEqual(0);
})
test('atan2', () => {
expect(Math.atan2(90, 15)).toEqual(1.4056476493802699);
expect(Math.atan2(15, 90)).toEqual(0.16514867741462683);
expectNumber(Math.atan2(15, 90)).toEqualDouble(0.16514867741462683);
})
test('atanh', () => {
// 解决精度问题
expect(Math.atanh(0)).toEqual(0.0);
expect(Math.atanh(0)).toEqual(0);
// expect(Math.atanh(0.5)).toEqual(0.5493061443340548);
})
test('cbrt', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册