DefinitelyTyped/types/uni-app/uni-app-tests.ts
折腾笔记 b49f2948b4 update types for uni-app (#37611)
* fix: getStoragetSync return value is incorrect.

* fix: The type of return value type of Storage is incorrect

* added parameter for GetStorageOptions.success

* added value parameter for setStorageSync

* fix setStorageSync with value: any

* update types for uni-app

* add class EditorContext for uni-app types

* fix lint for uni-app

* remove *.vue module for uni-app

* update types for uni-app

* update types for uni-app

* update types for uni-app

* update types for uni-app

* update types for uni-app

* update types for uni-app

* update types for uni-app

* update types for uni-app:fix boundingClientRect

* update types for uni-app: add onKeyboardHeightChange

* update types for uni-app: uni.checkSession

* update types for uni-app fixed uni.createMapContext

* update types for uni-app : add GetSystemInfoResult.safeArea

* update types for uni-app : uni.getSystemInfoSync
2019-08-22 08:39:34 -07:00

107 lines
2.0 KiB
TypeScript

uni.request({
url: 'https://dcloud.io',
success(res) {
uni.showToast({
title: res.data
});
},
fail(error) {
uni.showToast({
title: error.errMsg
});
}
});
uni.navigateTo({
url: 'index/index'
});
uni.showLoading({
title: 'test'
});
uni.createSelectorQuery().select('.test').context(res => {
const context = <EditorContext> res.context;
context.getContents({
success() {
console.log('getContents success');
}
});
});
uni.createSelectorQuery().select(".test").boundingClientRect(data => {
console.log(data);
}).exec();
const px: number = uni.upx2px(750);
uni.canvasToTempFilePath({
x: 0,
y: 0,
width: 100,
height: 100,
destWidth: 100,
destHeight: 100,
canvasId: 'test',
fileType: 'png',
quality: 1,
success() {
console.log('canvasToTempFilePath success');
}
});
const videoContext = uni.createVideoContext('test');
videoContext.play();
uni.onKeyboardHeightChange(({ height }) => {
console.log(height);
});
uni.checkSession({
success() {
console.log('success');
}
});
const mapContext = uni.createMapContext('map');
mapContext.getCenterLocation({
success(res) {
console.log(res.longitude);
}
});
mapContext.moveToLocation();
mapContext.translateMarker({
markerId: 1,
destination: {
latitude: 100,
longitude: 100
},
autoRotate: false,
rotate: 0,
animationEnd() {
console.log('animationEnd');
}
});
mapContext.includePoints({
points: [{
latitude: 100,
longitude: 100
}],
padding: [0]
});
mapContext.getRegion({
success(res) {
console.log(res.northeast);
}
});
mapContext.getScale({
success(res) {
console.log(res.scale);
}
});
const systemInfo = uni.getSystemInfoSync();
console.log(systemInfo.swanNativeVersion);
const safeArea = <SafeAreaResult> systemInfo.safeArea;
console.log(safeArea.top);