Skip to content

Commit 6682674

Browse files
authored
Update README.md
1 parent beb1435 commit 6682674

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ Native is only available for Vue components.
178178

179179
### HTML / Component ref
180180

181+
#### Vue ≤ 2.6
182+
183+
Due to the limitation, using ref is a little different from to Vue 3.
184+
185+
You can check [this](https://github.com/vuejs/composition-api#limitations) out for more information.
186+
181187
```tsx
182188
import { ComponentPublicInstance, defineComponent, onMounted } from '@vue/composition-api'
183189

@@ -206,9 +212,29 @@ const Wrapper = defineComponent({
206212
})
207213
```
208214

209-
Due to limitations, using ref is a little different from to Vue 3.
215+
#### Vue 2.7+
210216

211-
You can check [this](https://github.com/vuejs/composition-api#limitations) out for more information.
217+
Vue 2.7 has its built-in composition API support, and the behavior acts as the same as Vue 3.
218+
219+
```tsx
220+
import { ref, defineComponent } from 'vue'
221+
222+
const Example = defineComponent({
223+
setup () {
224+
const dogeRef = ref<HTMLElement>()
225+
226+
onMounted(() => {
227+
console.log(dogeRef.value)
228+
})
229+
230+
return () => (
231+
<div>
232+
<div ref={dogeRef}>Wow very doge</div>
233+
</div>
234+
)
235+
}
236+
})
237+
```
212238

213239
### Slot
214240

0 commit comments

Comments
 (0)