diff --git a/pages/component/web-view/web-view.test.js b/pages/component/web-view/web-view.test.js new file mode 100644 index 0000000000000000000000000000000000000000..bca16763be3d8ac30c0270a59d10513198af5cc7 --- /dev/null +++ b/pages/component/web-view/web-view.test.js @@ -0,0 +1,14 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('component-native-web-view', () => { + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/web-view/web-view'); + await page.waitFor(3000); + }); + + it('check_load_url', async () => { + expect(await page.data('loadError')).toBe(false) + }); +}); diff --git a/pages/component/web-view/web-view.uvue b/pages/component/web-view/web-view.uvue index fa6b517a656960b9eebdc3251a33fdb44cf1a4f4..2eca8cc46c27ba77808c9d23c7a3438811ba16b2 100644 --- a/pages/component/web-view/web-view.uvue +++ b/pages/component/web-view/web-view.uvue @@ -40,7 +40,8 @@ color: '#FF3333' } }, - webviewContext: null as WebviewContext | null + webviewContext: null as WebviewContext | null, + loadError: false } }, onReady() { @@ -66,6 +67,7 @@ console.log(JSON.stringify(event.detail)); }, error(event : WebViewErrorEvent) { + this.loadError = true console.log(JSON.stringify(event.detail)); }, loading(event : WebViewLoadingEvent) { @@ -94,4 +96,4 @@ .uni-btn-ml { margin-left: 10rpx; } - \ No newline at end of file +