-
-
-// DocsCode 7
-
-// DocsCode 8
-import { webview } from '@kit.ArkWeb'
-import { common } from '@kit.AbilityKit';
-import { Want } from '@kit.AbilityKit';
-import { BusinessError } from '@kit.BasicServicesKit';
-
-@Entry
-@Component
-struct WebComponent {
- controller: webview.WebviewController = new webview.WebviewController();
- build() {
- Column() {
- Column() {
- Web({ src: $rawfile('hello.html'), controller: this.controller })
- .onLoadIntercept((event) => {
- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext
- let want: Want = {
- deviceId: '', // deviceId为空表示本设备
- bundleName: '***', // 想要跳转的三方应用的bundleName
- moduleName: 'entry', // moduleName非必选
- abilityName: 'EntryAbility',
- parameters: {
- // 自定义参数传递页面信息
- router: 'index'
- }
- }
- context.startAbility(want).then(() => {
- console.log('success')
- }).catch((err: BusinessError) => {
- console.log('error:' + JSON.stringify(err))
- });
- return false;
- })
- }
- .layoutWeight(1)
- }
-
- }
-}
-// DocsCode 8
-
-// DocsCode 9
-
-
-
-
-
-
- Document
-
-
-跳转至三方应用
-
-
-// DocsCode 9
\ No newline at end of file
+// [End UseLabelAOpenPages_Three]
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets
new file mode 100644
index 00000000..5c2f5a40
--- /dev/null
+++ b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2024 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面
+*/
+
+// [Start UseLabelAOpenPages_Two]
+@Entry
+@Component
+struct Second {
+ build() {
+ Column() {
+ Text('这是本应用的第二个页面')
+ }
+ }
+}
+// [End UseLabelAOpenPages_Two]
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets b/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets
index 05e12fb0..4e240e35 100644
--- a/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets
+++ b/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets
@@ -17,13 +17,13 @@
* FAQ:如何使用Web组件下载pdf文件并展示给用户
*/
-// DocsCode 1
+// [Start UseWebDownloadPdf]
import { webview } from '@kit.ArkWeb';
import { common } from '@kit.AbilityKit';
import { request } from '@kit.BasicServicesKit';
-let context = getContext(this) as common.UIAbilityContext;
-let filesDir = context.filesDir;
+let context = AppStorage.get("context") as UIContext;
+let filesDir = context.getHostContext()!.filesDir;
let config: request.agent.Config = {
action: request.agent.Action.DOWNLOAD,
url: 'https://www-file.huawei.com/minisite/media/annual_report/annual_report_2023_cn.pdf',
@@ -47,7 +47,7 @@ let config: request.agent.Config = {
};
let createOnCallback = (progress: request.agent.Progress) => {
console.info('download task completed.');
- this.getUIContext().getPromptAction().showToast({
+ context.getPromptAction().showToast({
message: '下载完成',
duration: 2000
});
@@ -83,4 +83,4 @@ struct Index {
}
}
}
-// DocsCode 1
\ No newline at end of file
+// [End UseWebDownloadPdf]
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseAlertInWebview_Fragment.html b/ArkWebKit/entry/src/main/resources/rawfile/UseAlertInWebview_Fragment.html
new file mode 100644
index 00000000..f57650d2
--- /dev/null
+++ b/ArkWebKit/entry/src/main/resources/rawfile/UseAlertInWebview_Fragment.html
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2024 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* FAQ:如何在webview中使用H5中的alert
+*/
+
+// [Start UseAlertInWebview_Fragment]
+
+
+
+
+
+
+
WebView onAlert Demo
+
+
+
+
+// [End UseAlertInWebview_Fragment]
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html
new file mode 100644
index 00000000..2fbe58a9
--- /dev/null
+++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2024 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面
+*/
+
+// [Start UseLabelAOpenPages_Fragment_Five]
+
+
+
+
+
+
+ Document
+
+
+跳转至三方应用
+
+
+// [End UseLabelAOpenPages_Fragment_Five]
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html
new file mode 100644
index 00000000..cc7159d0
--- /dev/null
+++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2024 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面
+*/
+
+// [Start UseLabelAOpenPages_Fragment_Four]
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
+// [End UseLabelAOpenPages_Fragment_Four]
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html
new file mode 100644
index 00000000..57fecbed
--- /dev/null
+++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2024 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面
+*/
+
+// [Start UseLabelAOpenPages_Fragment_One]
+
+
+
+
+
+
+ Document
+
+
+
+
+
+// [End UseLabelAOpenPages_Fragment_One]
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html
new file mode 100644
index 00000000..3ebb5479
--- /dev/null
+++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2024 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面
+*/
+
+// [Start UseLabelAOpenPages_Fragment_Three]
+
+
+
+
+
+
+ Document
+
+
+
+ hello world
+
+
+ 我是本应用的第二个H5页面
+
+
+
+// [End UseLabelAOpenPages_Fragment_Three]
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html
new file mode 100644
index 00000000..eae4b1d2
--- /dev/null
+++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2024 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*
+* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面
+*/
+
+// [Start UseLabelAOpenPages_Fragment_Two]
+
+
+
+
+
+
+ Document
+
+
+