s2e22 two way binding
This commit is contained in:
parent
36812b72c4
commit
be0ddd00f0
16
app.js
16
app.js
@ -1,20 +1,6 @@
|
|||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
counter: 0,
|
name: "Tyrel"
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
},
|
},
|
||||||
methods:{
|
|
||||||
increase(step, event){
|
|
||||||
this.counter+= step;
|
|
||||||
},
|
|
||||||
updateCoordinates(event){
|
|
||||||
this.x = event.clientX;
|
|
||||||
this.y = event.clientY;
|
|
||||||
},
|
|
||||||
alertMe(event){
|
|
||||||
alert(event.target.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
10
index.html
10
index.html
@ -2,18 +2,12 @@
|
|||||||
<html lang="en" dir="ltr">
|
<html lang="en" dir="ltr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title></title>
|
|
||||||
<script src="vue.js"></script>
|
<script src="vue.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id='app'>
|
<div id='app'>
|
||||||
<button @click="increase(2, $event)">Click Me</button>
|
<input type="text" v-model="name">
|
||||||
<button @click="counter++">Click Me</button>
|
<p>{{name}}</p>
|
||||||
<p>{{ counter }}</p>
|
|
||||||
<p v-on:mousemove="updateCoordinates">Coordinates {{x}}, {{y}}
|
|
||||||
<span v-on:mousemove.stop.prevent=""> DEAD SPOT</span>
|
|
||||||
</p>
|
|
||||||
<input type="text" v-on:keyup.enter='alertMe'>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="app.js" charset="utf-8"></script>
|
<script src="app.js" charset="utf-8"></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user