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({
|
||||
el: '#app',
|
||||
data: {
|
||||
counter: 0,
|
||||
x: 0,
|
||||
y: 0,
|
||||
name: "Tyrel"
|
||||
},
|
||||
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">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<script src="vue.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id='app'>
|
||||
<button @click="increase(2, $event)">Click Me</button>
|
||||
<button @click="counter++">Click Me</button>
|
||||
<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'>
|
||||
<input type="text" v-model="name">
|
||||
<p>{{name}}</p>
|
||||
</div>
|
||||
|
||||
<script src="app.js" charset="utf-8"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user