Skip to content

Commit 177f0af

Browse files
committed
2.6: document Vue.observable
1 parent 190279d commit 177f0af

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/v2/api/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,33 @@ type: api
402402

403403
- **See also:** [Render Functions](../guide/render-function.html)
404404

405+
### Vue.observable( value )
406+
407+
> New in 2.6.0+
408+
409+
- **Arguments:**
410+
- `{object} value`
411+
412+
- **Usage:**
413+
414+
Explicitly creates a reactive object. This is what Vue performs internally on objects returned from a component's `data()` function.
415+
416+
The returned object can be used directly inside [render functions](../guide/render-function.html) and [computed properties](../guide/computed.html), and will trigger appropriate updates when mutated. It can be used as a minimal cross-component state store for simple scenarios.
417+
418+
``` js
419+
const obj = Vue.observable({ count: 0 })
420+
421+
const Demo = {
422+
render(h) {
423+
return h('button', {
424+
on: { click: () => { obj.count++ }}
425+
}, `count is: ${obj.count}`)
426+
}
427+
}
428+
```
429+
430+
- **See also:** [Reactivity in Depth](../guide/reactivity.html)
431+
405432
### Vue.version
406433

407434
- **Details**: Provides the installed version of Vue as a string. This is especially useful for community plugins and components, where you might use different strategies for different versions.

0 commit comments

Comments
 (0)