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

feat(composition api): useAttrs

上级 5400482a
<template>
<view>
<text id="attrs-class">attrs.class: {{attrs['class']}}</text>
<text id="attrs-msg" class='uni-common-mt'>attrs.msg: {{attrs['msg']}}</text>
</view>
</template>
<script setup>
import { useAttrs } from 'vue'
const attrs = useAttrs()
</script>
<style>
.foo {
padding: 10px;
background-color: #09c;
}
</style>
\ No newline at end of file
const PAGE_PATH = '/pages/composition-api/basic/use-attrs/use-attrs'
describe('useAttrs', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let page = null
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
})
it('basic', async () => {
const attrsClass = await page.$('#attrs-class')
expect(await attrsClass.text()).toBe('attrs.class: foo')
const attrsMsg = await page.$('#attrs-msg')
expect(await attrsMsg.text()).toBe('attrs.msg: msg')
})
} else {
it('other platform', () => {
expect(1).toBe(1)
})
}
})
\ No newline at end of file
<template>
<view class="page"> useAttrs </view>
<view class="page">
<Foo class="foo" msg="msg">
</Foo>
</view>
</template>
<script setup></script>
<script setup>
import Foo from './Foo.uvue'
</script>
\ No newline at end of file
......@@ -80,7 +80,7 @@
{
name: 'useAttrs',
url: 'use-attrs',
enable: false,
enable: true,
},
] as PageItem[],
}, {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册