diff --git a/pages.json b/pages.json
index a5ca3efe430dfee3d0c834c1b674c808410ce197..6e1475216df4f88c25aa8971f7d790fb01ae096a 100644
--- a/pages.json
+++ b/pages.json
@@ -1219,6 +1219,15 @@
}
},
// #endif
+ // #ifdef MP-WEIXIN
+ {
+ "path" : "pages/API/element-get-attribute/element-get-attribute",
+ "style" :
+ {
+ "navigationBarTitleText" : "getAttribute | 获取元素的属性值"
+ }
+ },
+ // #endif
// #ifdef APP-ANDROID || APP-IOS
{
"path": "pages/API/facial-recognition-meta-info/facial-recognition-meta-info",
@@ -3401,4 +3410,4 @@
]
}
]
-}
\ No newline at end of file
+}
diff --git a/pages/API/element-get-attribute/element-get-attribute.test.js b/pages/API/element-get-attribute/element-get-attribute.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..ef8504f3be5d186ce435388c680c3d5f3e01ff99
--- /dev/null
+++ b/pages/API/element-get-attribute/element-get-attribute.test.js
@@ -0,0 +1,29 @@
+jest.setTimeout(30000);
+describe('/pages/API/element-get-attribute/element-get-attribute', () => {
+ let page;
+ if (!process.env.uniTestPlatformInfo.startsWith('mp')) {
+ it('skip', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/API/element-get-attribute/element-get-attribute')
+ await page.waitFor(3000);
+ });
+ it('check getAttributeId', async () => {
+ await page.callMethod('getAttributeId')
+ expect(await page.data('attrId')).toEqual('box');
+ });
+ it('check setStyle getAttributeStyle', async () => {
+ await page.callMethod('setStyle')
+ await page.callMethod('getAttributeStyle')
+ expect(await page.data('attrStyle')).toEqual('background-color:#FFF000');
+ });
+ it('check scrollTo', async () => {
+ await page.callMethod('scrollTo')
+ await page.waitFor(100);
+ const scrollView = await page.$('.scroll-view_H')
+ expect(await scrollView.property('scrollLeft')).toBe(200);
+ });
+});
diff --git a/pages/API/element-get-attribute/element-get-attribute.uvue b/pages/API/element-get-attribute/element-get-attribute.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..f623659e97079b628d2eccfa92f57315bc99cbb0
--- /dev/null
+++ b/pages/API/element-get-attribute/element-get-attribute.uvue
@@ -0,0 +1,67 @@
+
+
+
+ 元素的id:{{ attrId }}
+ 元素的style:{{ attrStyle }}
+ 小程序端:getAttribute 获取元素的属性值,目前仅支持id、style
+
+
+
+
+
+ A
+ B
+ C
+
+
+
+
+
+