提交 f81850a6 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat: 补充多 style 和 script 示例及测试

上级 cbc761d9
......@@ -112,4 +112,9 @@
border: 1px solid #dfdfdf;
border-radius: 3px;
}
</style>
<style>
.text-red{
color: red;
}
</style>
\ No newline at end of file
......@@ -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": {
......
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
<template>
<view class="page">
<view class="mb-10 flex flex-row justify-between">
<text>msg: </text>
<text id="msg">{{ msg }}</text>
</view>
<!-- #ifndef APP-ANDROID -->
<view class="mb-10 flex flex-row justify-between">
<text>num: </text>
<text id="num">{{ num }}</text>
</view>
<!-- #endif -->
<view class="mb-10">
<text class="text-red">text red</text>
</view>
<view class="mb-10">
<text class="text-green">text green</text>
</view>
<view class="mb-10">
<text class="font-bold">font bold</text>
</view>
</view>
</template>
<script lang="uts">
export default {
data(){
return {
msg: 'Hello World'
}
}
}
</script>
<!-- #ifndef APP-ANDROID -->
<script setup lang="uts">
const num = ref(0)
</script>
<!-- #endif -->
<style>
.text-green {
color: green;
}
</style>
<style>
.font-bold {
font-weight: bold;
}
</style>
......@@ -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[]
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册