Skip to content

Commit d18b30c

Browse files
fenekkuchrisvfritz
authored andcommitted
Improved guide instance.md examples (vuejs#1458)
* Improved guide instance.md examples - Made some examples stronger by making sure that if their corresponding statements were false, the examples would indeed pick up on it: * comparing integers will not highlight that they are the integers from the same location in memory * fixed the freeze example such that if commented it out, it would work * Updated instance.md property getting
1 parent b3545b3 commit d18b30c

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/v2/guide/instance.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ var vm = new Vue({
4646
data: data
4747
})
4848

49-
// These reference the same object!
50-
vm.a === data.a // => true
49+
// Getting the property on the instance
50+
// returns the one from the original data
51+
vm.a == data.a // => true
5152

5253
// Setting the property on the instance
5354
// also affects the original data
@@ -88,19 +89,15 @@ Object.freeze(obj)
8889

8990
new Vue({
9091
el: '#app',
91-
data () {
92-
return {
93-
obj
94-
}
95-
}
92+
data: obj
9693
})
9794
```
9895

9996
```html
10097
<div id="app">
101-
<p>{{ obj.foo }}</p>
102-
<!-- this will no longer update obj.foo! -->
103-
<button @click="obj.foo = 'baz'">Change it</button>
98+
<p>{{ foo }}</p>
99+
<!-- this will no longer update foo! -->
100+
<button @click="foo = 'baz'">Change it</button>
104101
</div>
105102
```
106103

0 commit comments

Comments
 (0)