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

docs(component): 调整 ref 代码示例顺序

上级 a4759d5d
......@@ -245,26 +245,6 @@ uni-app x支持的组件包括:
-`uni-app x` 中,要访问 `$refs` 中的属性,需要使用索引方式。
::: preview
> uni-app js 引擎版
```ts
<template>
<view>
<text ref="textRef">text node</text>
<Foo ref="fooRef" />
</view>
</template>
<script lang="ts">
import type { ComponentPublicInstance } from 'vue'
export default {
onReady() {
const text = this.$refs.textRef as Element // 仅H5端支持
const foo = this.$refs.fooRef as ComponentPublicInstance
}
}
</script>
```
> uni-app x
```ts
// 选项式 API
......@@ -302,6 +282,26 @@ uni-app x支持的组件包括:
const fooRef = ref<null | ComponentPublicInstance>(null)
</script>
```
> uni-app js 引擎版
```ts
<template>
<view>
<text ref="textRef">text node</text>
<Foo ref="fooRef" />
</view>
</template>
<script lang="ts">
import type { ComponentPublicInstance } from 'vue'
export default {
onReady() {
const text = this.$refs.textRef as Element // 仅H5端支持
const foo = this.$refs.fooRef as ComponentPublicInstance
}
}
</script>
```
:::
## 监听页面生命周期
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册