From f81850a698ac0176dfa337af5f48c685132cb9b5 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Tue, 4 Jun 2024 19:51:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=E5=A4=9A=20style=20?= =?UTF-8?q?=E5=92=8C=20script=20=E7=A4=BA=E4=BE=8B=E5=8F=8A=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.uvue | 5 ++ pages.json | 6 +++ .../multiple-style-script.test.js | 27 ++++++++++ .../multiple-style-script.uvue | 49 +++++++++++++++++++ pages/index/index.uvue | 5 ++ 5 files changed, 92 insertions(+) create mode 100644 pages/examples/multiple-style-script/multiple-style-script.test.js create mode 100644 pages/examples/multiple-style-script/multiple-style-script.uvue diff --git a/App.uvue b/App.uvue index a45f143..6e0f1a4 100644 --- a/App.uvue +++ b/App.uvue @@ -112,4 +112,9 @@ border: 1px solid #dfdfdf; border-radius: 3px; } + + \ No newline at end of file diff --git a/pages.json b/pages.json index 5a3092d..4b62463 100644 --- a/pages.json +++ b/pages.json @@ -824,6 +824,12 @@ "navigationBarTitleText": "自定义组件中使用 class 定制另一个自定义组件根节点样式 组合式 API" } }, + { + "path": "pages/examples/multiple-style-script/multiple-style-script", + "style": { + "navigationBarTitleText": "多个 style 和 script" + } + }, { "path": "pages/type/type", "style": { diff --git a/pages/examples/multiple-style-script/multiple-style-script.test.js b/pages/examples/multiple-style-script/multiple-style-script.test.js new file mode 100644 index 0000000..4ca7374 --- /dev/null +++ b/pages/examples/multiple-style-script/multiple-style-script.test.js @@ -0,0 +1,27 @@ +const PAGE_PATH = '/pages/examples/multiple-style-script/multiple-style-script' + +describe(PAGE_PATH, () => { + const platformInfo = process.env.uniTestPlatformInfo.toLowerCase() + const isAndroid = platformInfo.startsWith('android') + const isWeb = platformInfo.startsWith('web') + let page + + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + it('测试多 style 和 script', async () => { + const msg = await page.$('#msg') + expect(await msg.text()).toBe('Hello World') + if (!isAndroid) { + const num = await page.$('#num') + expect(await num.text()).toBe('0') + } + const textRed = await page.$('.text-red') + expect(await textRed.style('color')).toBe(isWeb ? 'rgb(255, 0, 0)': '#FF0000') + const textGreen = await page.$('.text-green') + expect(await textGreen.style('color')).toBe(isWeb ? 'rgb(0, 128, 0)': '#008000') + const fontBold = await page.$('.font-bold') + expect(await fontBold.style('fontWeight')).toBe(isWeb ? '700' : 'bold') + }) +}) \ No newline at end of file diff --git a/pages/examples/multiple-style-script/multiple-style-script.uvue b/pages/examples/multiple-style-script/multiple-style-script.uvue new file mode 100644 index 0000000..52b2054 --- /dev/null +++ b/pages/examples/multiple-style-script/multiple-style-script.uvue @@ -0,0 +1,49 @@ + + + + + + + + + diff --git a/pages/index/index.uvue b/pages/index/index.uvue index 0afa7ac..9a14083 100644 --- a/pages/index/index.uvue +++ b/pages/index/index.uvue @@ -1142,6 +1142,11 @@ export default { id: 'unrecognized-component', name: 'unrecognized-component', url: 'unrecognized-component/unrecognized-component' + }, + { + id: 'multiple-style-script', + name: '多个 style 和 script', + url: 'multiple-style-script/multiple-style-script' } ] as Page[] }, -- GitLab