Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
8635bc49
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6388
Star
110
Fork
186
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
24
列表
看板
标记
里程碑
合并请求
2
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
24
Issue
24
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8635bc49
编写于
12月 18, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 兼容 web 端
上级
3e119088
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
257 addition
and
226 deletion
+257
-226
App.uvue
App.uvue
+2
-2
pages/API/get-app/get-app.test.js
pages/API/get-app/get-app.test.js
+9
-9
pages/API/get-app/get-app.uvue
pages/API/get-app/get-app.uvue
+17
-17
pages/API/get-current-pages/get-current-pages.test.js
pages/API/get-current-pages/get-current-pages.test.js
+11
-0
pages/API/get-launch-options-sync/get-launch-options-sync.uvue
.../API/get-launch-options-sync/get-launch-options-sync.uvue
+1
-1
pages/API/load-font-face/load-font-face.uvue
pages/API/load-font-face/load-font-face.uvue
+6
-6
pages/API/navigator/new-page/onLoad.test.js
pages/API/navigator/new-page/onLoad.test.js
+11
-9
pages/API/navigator/new-page/onLoad.uvue
pages/API/navigator/new-page/onLoad.uvue
+124
-111
pages/component/general-attribute/general-attribute.uvue
pages/component/general-attribute/general-attribute.uvue
+5
-0
pages/component/general-event/general-event.test.js
pages/component/general-event/general-event.test.js
+64
-70
pages/tabBar/API.uvue
pages/tabBar/API.uvue
+7
-1
未找到文件。
App.uvue
浏览文件 @
8635bc49
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
},
},
null: null as string | null,
null: null as string | null,
arr: [] as number[],
arr: [] as number[],
s
et: new Set<string>(),
myS
et: new Set<string>(),
map: new Map<string, any>(),
m
yM
ap: new Map<string, any>(),
func: (): string => {
func: (): string => {
return 'globalData func'
return 'globalData func'
}
}
...
...
pages/API/get-app/get-app.test.js
浏览文件 @
8635bc49
...
@@ -8,7 +8,7 @@ describe('getApp', () => {
...
@@ -8,7 +8,7 @@ describe('getApp', () => {
})
})
it
(
'
globalData
'
,
async
()
=>
{
it
(
'
globalData
'
,
async
()
=>
{
await
page
.
callMethod
(
'
getGlobalData
'
)
await
page
.
callMethod
(
'
getGlobalData
'
)
let
data
=
await
page
.
data
()
let
data
=
await
page
.
data
()
expect
(
data
.
originGlobalData
.
str
).
toBe
(
'
default globalData str
'
)
expect
(
data
.
originGlobalData
.
str
).
toBe
(
'
default globalData str
'
)
expect
(
data
.
originGlobalData
.
num
).
toBe
(
0
)
expect
(
data
.
originGlobalData
.
num
).
toBe
(
0
)
expect
(
data
.
originGlobalData
.
bool
).
toBe
(
false
)
expect
(
data
.
originGlobalData
.
bool
).
toBe
(
false
)
...
@@ -19,11 +19,11 @@ describe('getApp', () => {
...
@@ -19,11 +19,11 @@ describe('getApp', () => {
})
})
expect
(
data
.
originGlobalData
.
arr
).
toEqual
([])
expect
(
data
.
originGlobalData
.
arr
).
toEqual
([])
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
data
.
originGlobalData
.
s
et
).
toEqual
([])
expect
(
data
.
originGlobalData
.
myS
et
).
toEqual
([])
}
else
{
}
else
{
expect
(
data
.
originGlobalData
.
s
et
).
toEqual
({})
expect
(
data
.
originGlobalData
.
myS
et
).
toEqual
({})
}
}
expect
(
data
.
originGlobalData
.
map
).
toEqual
({})
expect
(
data
.
originGlobalData
.
m
yM
ap
).
toEqual
({})
expect
(
data
.
originGlobalDataFuncRes
).
toBe
(
'
globalData func
'
)
expect
(
data
.
originGlobalDataFuncRes
).
toBe
(
'
globalData func
'
)
await
page
.
callMethod
(
'
setGlobalData
'
)
await
page
.
callMethod
(
'
setGlobalData
'
)
data
=
await
page
.
data
()
data
=
await
page
.
data
()
...
@@ -37,18 +37,18 @@ describe('getApp', () => {
...
@@ -37,18 +37,18 @@ describe('getApp', () => {
})
})
expect
(
data
.
newGlobalData
.
arr
).
toEqual
([
1
,
2
,
3
])
expect
(
data
.
newGlobalData
.
arr
).
toEqual
([
1
,
2
,
3
])
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
data
.
newGlobalData
.
s
et
).
toEqual
([
'
a
'
,
'
b
'
,
'
c
'
])
expect
(
data
.
newGlobalData
.
myS
et
).
toEqual
([
'
a
'
,
'
b
'
,
'
c
'
])
}
else
{
}
else
{
expect
(
data
.
originGlobalData
.
s
et
).
toEqual
({})
expect
(
data
.
originGlobalData
.
myS
et
).
toEqual
({})
}
}
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
data
.
newGlobalData
.
map
).
toEqual
({
expect
(
data
.
newGlobalData
.
m
yM
ap
).
toEqual
({
'
a
'
:
1
,
'
a
'
:
1
,
'
b
'
:
2
,
'
b
'
:
2
,
'
c
'
:
3
'
c
'
:
3
})
})
}
else
{
}
else
{
expect
(
data
.
originGlobalData
.
map
).
toEqual
({})
expect
(
data
.
originGlobalData
.
m
yM
ap
).
toEqual
({})
}
}
expect
(
data
.
newGlobalDataFuncRes
).
toBe
(
'
new globalData func
'
)
expect
(
data
.
newGlobalDataFuncRes
).
toBe
(
'
new globalData func
'
)
})
})
...
@@ -59,4 +59,4 @@ describe('getApp', () => {
...
@@ -59,4 +59,4 @@ describe('getApp', () => {
expect
(
newLifeCycleNum
-
oldLifeCycleNum
).
toBe
(
100
)
expect
(
newLifeCycleNum
-
oldLifeCycleNum
).
toBe
(
100
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
oldLifeCycleNum
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
oldLifeCycleNum
)
})
})
})
})
\ No newline at end of file
pages/API/get-app/get-app.uvue
浏览文件 @
8635bc49
...
@@ -14,11 +14,11 @@
...
@@ -14,11 +14,11 @@
<text class="uni-common-mt">globalData object: {{ originGlobalData.obj }}</text>
<text class="uni-common-mt">globalData object: {{ originGlobalData.obj }}</text>
<text class="uni-common-mt">globalData null: {{ originGlobalData.null }}</text>
<text class="uni-common-mt">globalData null: {{ originGlobalData.null }}</text>
<text class="uni-common-mt">globalData array: {{ originGlobalData.arr }}</text>
<text class="uni-common-mt">globalData array: {{ originGlobalData.arr }}</text>
<text class="uni-common-mt">globalData Set: {{ originGlobalData.
s
et }}</text>
<text class="uni-common-mt">globalData Set: {{ originGlobalData.
myS
et }}</text>
<text class="uni-common-mt">globalData Map: {{ originGlobalData.map }}</text>
<text class="uni-common-mt">globalData Map: {{ originGlobalData.m
yM
ap }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ originGlobalDataFuncRes }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ originGlobalDataFuncRes }}</text>
</template>
</template>
<button @click="setGlobalData" class="uni-common-mt">
s
et globalData</button>
<button @click="setGlobalData" class="uni-common-mt">
myS
et globalData</button>
<template v-if="newGlobalData.bool">
<template v-if="newGlobalData.bool">
<text class="uni-common-mt bold">更新后的 globalData:</text>
<text class="uni-common-mt bold">更新后的 globalData:</text>
<text class="uni-common-mt">globalData string: {{ newGlobalData.str }}</text>
<text class="uni-common-mt">globalData string: {{ newGlobalData.str }}</text>
...
@@ -27,8 +27,8 @@
...
@@ -27,8 +27,8 @@
<text class="uni-common-mt">globalData object: {{ newGlobalData.obj }}</text>
<text class="uni-common-mt">globalData object: {{ newGlobalData.obj }}</text>
<text class="uni-common-mt">globalData null: {{ newGlobalData.null }}</text>
<text class="uni-common-mt">globalData null: {{ newGlobalData.null }}</text>
<text class="uni-common-mt">globalData array: {{ newGlobalData.arr }}</text>
<text class="uni-common-mt">globalData array: {{ newGlobalData.arr }}</text>
<text class="uni-common-mt">globalData Set: {{ newGlobalData.
s
et }}</text>
<text class="uni-common-mt">globalData Set: {{ newGlobalData.
myS
et }}</text>
<text class="uni-common-mt">globalData Map: {{ newGlobalData.map }}</text>
<text class="uni-common-mt">globalData Map: {{ newGlobalData.m
yM
ap }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ newGlobalDataFuncRes }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ newGlobalDataFuncRes }}</text>
</template>
</template>
<view class="uni-common-mt hr"></view>
<view class="uni-common-mt hr"></view>
...
@@ -53,8 +53,8 @@
...
@@ -53,8 +53,8 @@
obj : UTSJSONObject,
obj : UTSJSONObject,
null : string | null,
null : string | null,
arr : number[],
arr : number[],
s
et : Set<string>,
myS
et : Set<string>,
map : Map<string, any>,
m
yM
ap : Map<string, any>,
func : () => string
func : () => string
}
}
import { state, setLifeCycleNum } from '@/store/index.uts'
import { state, setLifeCycleNum } from '@/store/index.uts'
...
@@ -73,8 +73,8 @@
...
@@ -73,8 +73,8 @@
} as UTSJSONObject,
} as UTSJSONObject,
null: null,
null: null,
arr: [] as number[],
arr: [] as number[],
s
et: new Set<string>(),
myS
et: new Set<string>(),
map: new Map<string, any>(),
m
yM
ap: new Map<string, any>(),
func: () : string => ''
func: () : string => ''
} as MyGlobalData,
} as MyGlobalData,
originGlobalDataFuncRes: '',
originGlobalDataFuncRes: '',
...
@@ -89,8 +89,8 @@
...
@@ -89,8 +89,8 @@
} as UTSJSONObject,
} as UTSJSONObject,
null: null,
null: null,
arr: [] as number[],
arr: [] as number[],
s
et: new Set<string>(),
myS
et: new Set<string>(),
map: new Map<string, any>(),
m
yM
ap: new Map<string, any>(),
func: () : string => ''
func: () : string => ''
} as MyGlobalData,
} as MyGlobalData,
newGlobalDataFuncRes: '',
newGlobalDataFuncRes: '',
...
@@ -109,8 +109,8 @@
...
@@ -109,8 +109,8 @@
this.originGlobalData.obj = app.globalData.obj
this.originGlobalData.obj = app.globalData.obj
this.originGlobalData.null = app.globalData.null
this.originGlobalData.null = app.globalData.null
this.originGlobalData.arr = app.globalData.arr
this.originGlobalData.arr = app.globalData.arr
this.originGlobalData.
set = app.globalData.s
et
this.originGlobalData.
mySet = app.globalData.myS
et
this.originGlobalData.m
ap = app.globalData.m
ap
this.originGlobalData.m
yMap = app.globalData.myM
ap
this.originGlobalData.func = app.globalData.func
this.originGlobalData.func = app.globalData.func
this.originGlobalDataFuncRes = this.originGlobalData.func()
this.originGlobalDataFuncRes = this.originGlobalData.func()
},
},
...
@@ -127,8 +127,8 @@
...
@@ -127,8 +127,8 @@
}
}
app.globalData.null = 'not null'
app.globalData.null = 'not null'
app.globalData.arr = [1, 2, 3]
app.globalData.arr = [1, 2, 3]
app.globalData.
s
et = new Set(['a', 'b', 'c'])
app.globalData.
myS
et = new Set(['a', 'b', 'c'])
app.globalData.map = new Map([
app.globalData.m
yM
ap = new Map([
['a', 1],
['a', 1],
['b', 2],
['b', 2],
['c', 3]
['c', 3]
...
@@ -143,8 +143,8 @@
...
@@ -143,8 +143,8 @@
this.newGlobalData.obj = app.globalData.obj
this.newGlobalData.obj = app.globalData.obj
this.newGlobalData.null = app.globalData.null
this.newGlobalData.null = app.globalData.null
this.newGlobalData.arr = app.globalData.arr
this.newGlobalData.arr = app.globalData.arr
this.newGlobalData.
set = app.globalData.s
et
this.newGlobalData.
mySet = app.globalData.myS
et
this.newGlobalData.m
ap = app.globalData.m
ap
this.newGlobalData.m
yMap = app.globalData.myM
ap
this.newGlobalData.func = app.globalData.func
this.newGlobalData.func = app.globalData.func
this.newGlobalDataFuncRes = this.newGlobalData.func()
this.newGlobalDataFuncRes = this.newGlobalData.func()
},
},
...
...
pages/API/get-current-pages/get-current-pages.test.js
浏览文件 @
8635bc49
...
@@ -4,6 +4,17 @@ const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
...
@@ -4,6 +4,17 @@ const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
describe
(
'
getCurrentPages
'
,
()
=>
{
describe
(
'
getCurrentPages
'
,
()
=>
{
let
page
let
page
it
(
'
getCurrentPages
'
,
async
()
=>
{
it
(
'
getCurrentPages
'
,
async
()
=>
{
// web 端等待应用首页加载完成
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
const
waitTime
=
process
.
env
.
uniTestPlatformInfo
.
includes
(
'
safari
'
)
?
5000
:
1000
await
new
Promise
((
resolve
)
=>
{
setTimeout
(()
=>
{
resolve
()
},
waitTime
)
})
}
page
=
await
program
.
switchTab
(
HOME_PAGE_PATH
)
page
=
await
program
.
switchTab
(
HOME_PAGE_PATH
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
1000
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
...
...
pages/API/get-launch-options-sync/get-launch-options-sync.uvue
浏览文件 @
8635bc49
...
@@ -24,7 +24,7 @@ export default {
...
@@ -24,7 +24,7 @@ export default {
getLaunchOptionsSync() {
getLaunchOptionsSync() {
const launchOptions = uni.getLaunchOptionsSync()
const launchOptions = uni.getLaunchOptionsSync()
this.launchOptionsPath = launchOptions.path
this.launchOptionsPath = launchOptions.path
if (launchOptions.path == this.homePagePath) {
if (launchOptions.path ==
= this.homePagePath || `/${launchOptions.path}` ===
this.homePagePath) {
this.checked = true
this.checked = true
}
}
},
},
...
...
pages/API/load-font-face/load-font-face.uvue
浏览文件 @
8635bc49
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
uni.loadFontFace({
uni.loadFontFace({
global: true,
global: true,
family: 'UniFontFamily',
family: 'UniFontFamily',
source:
'/static/font/uni.ttf'
,
source:
"url('/static/font/uni.ttf')"
,
success() {
success() {
console.log('global loadFontFace uni.ttf success')
console.log('global loadFontFace uni.ttf success')
},
},
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
uni.loadFontFace({
uni.loadFontFace({
family: 'AlimamaDaoLiTiTTF',
family: 'AlimamaDaoLiTiTTF',
source:
source:
'https://native-res.dcloud.net.cn/uni-app-x/static/font/AlimamaDaoLiTi.ttf'
,
"url('https://native-res.dcloud.net.cn/uni-app-x/static/font/AlimamaDaoLiTi.ttf')"
,
success() {
success() {
console.log('loadFontFace Remote AlimamaDaoLiTi.ttf success')
console.log('loadFontFace Remote AlimamaDaoLiTi.ttf success')
},
},
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
})
})
uni.loadFontFace({
uni.loadFontFace({
family: 'AlimamaDaoLiTiOTF',
family: 'AlimamaDaoLiTiOTF',
source:
'/static/font/AlimamaDaoLiTi.otf'
,
source:
"url('/static/font/AlimamaDaoLiTi.otf')"
,
success() {
success() {
console.log('loadFontFace AlimamaDaoLiTi.otf success')
console.log('loadFontFace AlimamaDaoLiTi.otf success')
},
},
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
})
})
uni.loadFontFace({
uni.loadFontFace({
family: 'AlimamaDaoLiTiWOFF',
family: 'AlimamaDaoLiTiWOFF',
source:
'/static/font/AlimamaDaoLiTi.woff'
,
source:
"url('/static/font/AlimamaDaoLiTi.woff')"
,
success() {
success() {
console.log('loadFontFace AlimamaDaoLiTi.woff success')
console.log('loadFontFace AlimamaDaoLiTi.woff success')
},
},
...
@@ -78,7 +78,7 @@
...
@@ -78,7 +78,7 @@
})
})
uni.loadFontFace({
uni.loadFontFace({
family: 'AlimamaDaoLiTiWOFF2',
family: 'AlimamaDaoLiTiWOFF2',
source:
'/static/font/AlimamaDaoLiTi.woff2'
,
source:
"url('/static/font/AlimamaDaoLiTi.woff2')"
,
success() {
success() {
console.log('loadFontFace AlimamaDaoLiTi.woff2 success')
console.log('loadFontFace AlimamaDaoLiTi.woff2 success')
},
},
...
@@ -105,4 +105,4 @@
...
@@ -105,4 +105,4 @@
.line-height-40 {
.line-height-40 {
line-height: 40px;
line-height: 40px;
}
}
</style>
</style>
\ No newline at end of file
pages/API/navigator/new-page/onLoad.test.js
浏览文件 @
8635bc49
...
@@ -9,7 +9,7 @@ describe("onLoad", () => {
...
@@ -9,7 +9,7 @@ describe("onLoad", () => {
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
adjustData
"
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
adjustData
"
);
await
page
.
waitFor
(
100
);
await
page
.
waitFor
(
100
0
);
const
image
=
await
program
.
screenshot
();
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
});
...
@@ -17,17 +17,19 @@ describe("onLoad", () => {
...
@@ -17,17 +17,19 @@ describe("onLoad", () => {
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
navigateTo
"
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
navigateTo
"
);
await
page
.
waitFor
(
100
);
await
page
.
waitFor
(
100
0
);
page
=
await
program
.
currentPage
();
page
=
await
program
.
currentPage
();
expect
(
page
.
path
).
toBe
(
TARGET_PAGE_PATH
.
substring
(
1
));
expect
(
page
.
path
).
toBe
(
TARGET_PAGE_PATH
.
substring
(
1
));
});
});
it
(
"
navigateBack
"
,
async
()
=>
{
it
(
"
navigateBack
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
await
page
.
waitFor
(
'
view
'
);
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
navigateBack
"
);
await
page
.
waitFor
(
'
view
'
);
page
=
await
program
.
currentPage
();
await
page
.
callMethod
(
"
navigateToOnLoadWithType
"
,
"
navigateBack
"
);
await
page
.
waitFor
(
'
view
'
);
await
page
.
waitFor
(
'
view
'
);
expect
(
page
.
path
).
toBe
(
INTERMEDIATE_PAGE_PATH
.
substring
(
1
));
page
=
await
program
.
currentPage
();
expect
(
page
.
path
).
toBe
(
INTERMEDIATE_PAGE_PATH
.
substring
(
1
));
}
});
});
it
(
"
redirectTo
"
,
async
()
=>
{
it
(
"
redirectTo
"
,
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
);
...
@@ -126,4 +128,4 @@ describe("onLoad", () => {
...
@@ -126,4 +128,4 @@ describe("onLoad", () => {
failureThresholdType
:
"
percent
"
,
failureThresholdType
:
"
percent
"
,
});
});
});
});
});
});
pages/API/navigator/new-page/onLoad.uvue
浏览文件 @
8635bc49
<template>
<template>
<view class="uni-padding-wrap">
<view class="uni-padding-wrap">
<page-head title="onLoad 生命周期调用 uni api 测试" />
<page-head title="onLoad 生命周期调用 uni api 测试" />
<text v-if="isTrue">v-if with true</text>
<text v-if="isTrue">v-if with true</text>
<text v-if="isFalse">v-if with false</text>
<text v-if="isFalse">v-if with false</text>
<text v-show="isTrue">v-show with true</text>
<text v-show="isTrue">v-show with true</text>
<text v-show="isFalse">v-show with false</text>
<text v-show="isFalse">v-show with false</text>
<text>msg: {{ msg }}</text>
<text>msg: {{ msg }}</text>
</view>
</view>
</template>
</template>
<script lang="uts">
<script lang="uts">
export default {
export default {
data() {
data() {
return {
return {
isTrue: false,
isTrue: false,
isFalse: true,
isFalse: true,
msg: 'default msg'
msg: 'default msg'
}
}
},
},
onLoad(options: OnLoadOptions) {
onLoad(options : OnLoadOptions) {
const type = options.get('type')
const type = options['type']
switch (type) {
switch (type) {
case 'adjustData':
case 'adjustData':
this.adjustData()
this.adjustData()
break;
break;
case 'navigateTo':
case 'navigateTo':
this.navigateTo()
this.navigateTo()
break;
break;
case 'navigateBack':
case 'navigateBack':
this.navigateBack()
this.navigateBack()
break;
break;
case 'redirectTo':
case 'redirectTo':
this.redirectTo()
this.redirectTo()
break;
break;
case 'reLaunch':
case 'reLaunch':
this.reLaunch()
this.reLaunch()
break;
break;
case 'switchTab':
case 'switchTab':
this.switchTab()
this.switchTab()
break;
break;
case 'showToast':
case 'showToast':
this.showToast()
this.showToast()
break;
break;
case 'showLoading':
case 'showLoading':
this.showLoading()
this.showLoading()
break;
break;
case 'showModal':
case 'showModal':
this.showModal()
this.showModal()
break;
break;
case 'showActionSheet':
case 'showActionSheet':
this.showActionSheet()
this.showActionSheet()
break;
break;
}
}
},
},
methods: {
// #ifdef WEB
adjustData(){
onUnload() {
this.isTrue = true
// web 端页面销毁前,关闭 modal 和 actionsheet
this.isFalse = false
const modalBtn = document.querySelector('.uni-modal__btn')
this.msg = 'new msg'
if (modalBtn) {
},
modalBtn.click()
navigateTo(){
}
uni.navigateTo({
const actionSheetBtn = document.querySelector('.uni-actionsheet__action .uni-actionsheet__cell')
url: '/pages/API/navigator/new-page/new-page-3'
if (actionSheetBtn) {
})
actionSheetBtn.click()
},
}
navigateBack(){
},
uni.navigateBack()
// #endif
},
methods: {
redirectTo(){
adjustData() {
uni.redirectTo({
this.isTrue = true
url: '/pages/API/navigator/new-page/new-page-3'
this.isFalse = false
})
this.msg = 'new msg'
},
},
reLaunch(){
navigateTo() {
uni.reLaunch({
uni.navigateTo({
url: '/pages/API/navigator/new-page/new-page-3'
url: '/pages/API/navigator/new-page/new-page-3'
})
})
},
},
switchTab(){
navigateBack() {
uni.switchTab({
uni.navigateBack()
url: '/pages/tabBar/component'
},
})
redirectTo() {
},
uni.redirectTo({
showToast(){
url: '/pages/API/navigator/new-page/new-page-3'
uni.showToast({
})
title: 'test title',
},
icon: 'success',
reLaunch() {
duration: 2000
uni.reLaunch({
})
url: '/pages/API/navigator/new-page/new-page-3'
},
})
showLoading(){
},
uni.showLoading({
switchTab() {
title: 'test title',
uni.switchTab({
})
url: '/pages/tabBar/component'
},
})
showModal(){
},
uni.showModal({
showToast() {
title: 'test title',
uni.showToast({
content: 'test content',
title: 'test title',
})
icon: 'success',
},
duration: 2000
showActionSheet(){
})
uni.showActionSheet({
},
title: 'test title',
showLoading() {
itemList: ['1', '2', '3']
uni.showLoading({
})
title: 'test title',
}
})
}
},
}
showModal() {
</script>
uni.showModal({
title: 'test title',
content: 'test content'
})
},
showActionSheet() {
uni.showActionSheet({
title: 'test title',
itemList: ['1', '2', '3']
})
}
}
}
</script>
pages/component/general-attribute/general-attribute.uvue
浏览文件 @
8635bc49
...
@@ -76,7 +76,12 @@ export default {
...
@@ -76,7 +76,12 @@ export default {
this.validateGeneralAttrText = '基础属性 id 验证失败'
this.validateGeneralAttrText = '基础属性 id 验证失败'
return
return
}
}
// #ifdef APP-ANDROID
if (!generalTarget.classList.includes('general-class')) {
if (!generalTarget.classList.includes('general-class')) {
// #endif
// #ifdef WEB
if (!Array.from(generalTarget.classList).includes('general-class')) {
// #endif
this.validateGeneralAttrText = '基础属性 class 验证失败'
this.validateGeneralAttrText = '基础属性 class 验证失败'
return
return
}
}
...
...
pages/component/general-event/general-event.test.js
浏览文件 @
8635bc49
const
PAGE_PATH
=
'
/pages/component/general-event/general-event
'
const
PAGE_PATH
=
'
/pages/component/general-event/general-event
'
describe
(
'
event trigger sequence
'
,
()
=>
{
describe
(
'
event trigger sequence
'
,
()
=>
{
let
page
let
page
let
el
let
el
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
waitFor
(
'
view
'
)
el
=
await
page
.
$
(
'
.target
'
)
el
=
await
page
.
$
(
'
.target
'
)
})
})
it
(
'
touch
'
,
async
()
=>
{
it
(
'
touch
'
,
async
()
=>
{
await
el
.
touchstart
({
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
touches
:
[
await
el
.
touchstart
({
{
touches
:
[{
identifier
:
1
,
identifier
:
1
,
pageX
:
100
,
pageX
:
100
,
pageY
:
100
,
pageY
:
100
,
},
},
],
],
changedTouches
:
[{
changedTouches
:
[
identifier
:
1
,
{
pageX
:
100
,
identifier
:
1
,
pageY
:
100
,
pageX
:
100
,
},
],
pageY
:
100
,
})
},
await
el
.
touchmove
({
],
touches
:
[{
})
identifier
:
1
,
await
el
.
touchmove
({
pageX
:
100
,
touches
:
[
pageY
:
100
,
{
},
],
identifier
:
1
,
changedTouches
:
[{
pageX
:
100
,
identifier
:
1
,
pageY
:
100
,
pageX
:
101
,
},
pageY
:
101
,
],
},
],
changedTouches
:
[
})
{
await
el
.
touchend
({
identifier
:
1
,
touches
:
[],
pageX
:
101
,
changedTouches
:
[{
pageY
:
101
,
identifier
:
1
,
},
pageX
:
101
,
],
pageY
:
101
,
})
},
],
await
el
.
touchend
({
})
touches
:
[],
const
data
=
await
page
.
data
()
changedTouches
:
[
expect
(
data
.
onTouchStartTime
).
toBeLessThanOrEqual
(
data
.
onTouchMoveTime
);
{
expect
(
data
.
onTouchMoveTime
).
toBeLessThanOrEqual
(
data
.
onTouchEndTime
);
identifier
:
1
,
}
pageX
:
101
,
})
pageY
:
101
,
},
it
(
'
click
'
,
async
()
=>
{
],
await
el
.
tap
()
})
const
data
=
await
page
.
data
()
const
data
=
await
page
.
data
()
expect
(
data
.
onTapTime
).
toBeLessThanOrEqual
(
data
.
onClickTime
)
expect
(
data
.
onTouchStartTime
).
toBeLessThanOrEqual
(
data
.
onTouchMoveTime
);
})
expect
(
data
.
onTouchMoveTime
).
toBeLessThanOrEqual
(
data
.
onTouchEndTime
);
})
it
(
'
longPress
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
it
(
'
click
'
,
async
()
=>
{
await
el
.
longpress
()
await
el
.
tap
()
const
data
=
await
page
.
data
()
const
data
=
await
page
.
data
()
expect
(
data
.
onLongPressTime
).
toBeGreaterThan
(
0
)
expect
(
data
.
onTapTime
).
toBeLessThanOrEqual
(
data
.
onClickTime
)
}
})
})
it
(
'
longPress
'
,
async
()
=>
{
await
el
.
longpress
()
const
data
=
await
page
.
data
()
expect
(
data
.
onLongPressTime
).
toBeGreaterThan
(
0
)
})
})
})
pages/tabBar/API.uvue
浏览文件 @
8635bc49
...
@@ -153,7 +153,13 @@
...
@@ -153,7 +153,13 @@
{
{
name: 'element元素',
name: 'element元素',
url: 'get-element-by-id',
url: 'get-element-by-id',
api: ["getElementById"]
api: ["getElementById"],
// #ifdef APP-ANDROID
enable: true,
// #endif
// #ifndef APP-ANDROID
enable: false,
// #endif
},
},
{
{
name: 'element draw',
name: 'element draw',
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录