diff --git a/pages.json b/pages.json
index 9cd8ca8f7b8bc7e4197c08757debcce94e08e222..504b6914286a321e5994f915e18e614f8739ee31 100644
--- a/pages.json
+++ b/pages.json
@@ -1107,6 +1107,15 @@
"navigationBarTitleText": "createSelectorQuery | 创建 SelectorQuery 实例"
}
},
+ // #ifndef APP
+ {
+ "path": "pages/API/get-native-view/get-native-view",
+ "style": {
+ "navigationBarTitleText": "获取原生view",
+ "backgroundColor": "#F8F8F8"
+ }
+ },
+ // #endif
{
"path": "pages/API/create-canvas-context-async/create-canvas-context-async",
"group": "1,16,3",
@@ -2730,4 +2739,4 @@
]
}
]
-}
\ No newline at end of file
+}
diff --git a/pages/API/get-native-view/get-native-view.test.js b/pages/API/get-native-view/get-native-view.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..05f81a52b3066e0341954b0816af4d296630901d
--- /dev/null
+++ b/pages/API/get-native-view/get-native-view.test.js
@@ -0,0 +1,42 @@
+describe('get-native-view', () => {
+ if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
+ it('object', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ let page
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/API/get-native-view/get-native-view')
+ await page.waitFor('web-view')
+ })
+
+ //检测view标签原生View是否匹配
+ it('check_view_native_view', async () => {
+ page.waitFor(100)
+ const value = await page.callMethod('checkViewNativeView')
+ expect(value).toBe(true)
+ })
+
+ //检测intpu标签原生View是否匹配
+ it('check_input_native_view', async () => {
+ page.waitFor(100)
+ const value = await page.callMethod('checkInputNativeView')
+ expect(value).toBe(true)
+ })
+
+ //检测textarea标签原生View是否匹配
+ it('check_textarea_native_view', async () => {
+ page.waitFor(100)
+ const value = await page.callMethod('checkTextareaNativeView')
+ expect(value).toBe(true)
+ })
+
+ //检测view标签原生View是否匹配
+ it('check_web_view_native_view', async () => {
+ page.waitFor(100)
+ const value = await page.callMethod('checkWebViewNativeView')
+ expect(value).toBe(true)
+ })
+
+})
diff --git a/pages/API/get-native-view/get-native-view.uvue b/pages/API/get-native-view/get-native-view.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..47df62daa134e2c549410ab08a970e71e342b1e7
--- /dev/null
+++ b/pages/API/get-native-view/get-native-view.uvue
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uts-get-native-view/utssdk/app-android/index.uts b/uni_modules/uts-get-native-view/utssdk/app-android/index.uts
index 4824c1fe417526b947b32d7ea7f00ce0d84b353d..ad8a2f9f2c02d2e653196ece2fb8cb25b94e6d4d 100644
--- a/uni_modules/uts-get-native-view/utssdk/app-android/index.uts
+++ b/uni_modules/uts-get-native-view/utssdk/app-android/index.uts
@@ -1,6 +1,8 @@
-import { CanWebViewGoBack, CanWebViewGoForward, HasNativeView} from "../interface";
+import { CanWebViewGoBack, CanWebViewGoForward, HasNativeView, CheckWebViewNativeView, CheckInputNativeView, CheckTextareaNativeView, CheckViewNativeView} from "../interface";
import WebView from 'android.webkit.WebView';
import View from "android.view.View"
+import EditText from "android.widget.EditText"
+import ViewGroup from "android.view.ViewGroup"
export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string) : boolean {
const view = uni.getElementById(elementId)?.getAndroidView();
@@ -16,3 +18,23 @@ export const hasNativeView : HasNativeView = function (elementId : string) : boo
const view = uni.getElementById(elementId)?.getAndroidView();
return view != null;
}
+
+export const checkWebViewNativeView: CheckWebViewNativeView = function (elementId : string) : boolean {
+ const view = uni.getElementById(elementId)?.getAndroidView();
+ return view != null;
+}
+
+export const checkInputNativeView: CheckInputNativeView = function (elementId : string) : boolean {
+ const view = uni.getElementById(elementId)?.getAndroidView();
+ return view != null;
+}
+
+export const checkTextareaNativeView: CheckViewNativeView = function (elementId : string) : boolean {
+ const view = uni.getElementById(elementId)?.getAndroidView();
+ return view != null;
+}
+
+export const checkViewNativeView: CheckViewNativeView = function (elementId : string) : boolean {
+ const view = uni.getElementById(elementId)?.getAndroidView();
+ return view != null;
+}
diff --git a/uni_modules/uts-get-native-view/utssdk/interface.uts b/uni_modules/uts-get-native-view/utssdk/interface.uts
index eaf60e86f91998811c4f89ba6601d2b68c34e5d1..31b29b5303fd67d87aa860ba974835b943b2e819 100644
--- a/uni_modules/uts-get-native-view/utssdk/interface.uts
+++ b/uni_modules/uts-get-native-view/utssdk/interface.uts
@@ -12,3 +12,23 @@ export type CanWebViewGoForward = (elementId : string) => boolean
* 是否存在原生view
*/
export type HasNativeView = (elementId : string) => boolean
+
+/**
+ * 检测web-view标签获取到的原生View是否符合预期的原生View
+ */
+export type CheckWebViewNativeView = (elementId : string) => boolean
+
+/**
+ * 检测input标签获取到的原生View是否符合预期的原生View
+ */
+export type CheckInputNativeView = (elementId : string) => boolean
+
+/**
+ * 检测textarea标签获取到的原生View是否符合预期的原生View
+ */
+export type CheckTextareaNativeView = (elementId : string) => boolean
+
+/**
+ * 检测view标签获取到的原生View是否符合预期的原生View
+ */
+export type CheckViewNativeView = (elementId : string) => boolean