[ADD]事件处理器
This commit is contained in:
parent
c914434727
commit
28649469f4
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
||||
<!--[if gt IE 8]> <html class="no-js"> <!--<![endif]-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title></title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="">
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<!--[if lt IE 7]>
|
||||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
|
||||
<![endif]-->
|
||||
|
||||
<div id="example-1">
|
||||
<button v-on:click="counter += 1">增加1</button>
|
||||
<p> 这个按钮被点击了{{counter}}次</p>
|
||||
</div>
|
||||
|
||||
<div id="example-2">
|
||||
<button v-on:click="greet">Greet</button>
|
||||
</div>
|
||||
|
||||
<div id="example-3">
|
||||
<button v-on:click="say('hi')">Say hi</button>
|
||||
<button v-on:click="say('what')">Say what</button>
|
||||
<button v-on:click="warn('Form cannot be submitted yet', $event)">Submit</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var example1 = new Vue({
|
||||
el: '#example-1',
|
||||
data: {
|
||||
counter: 0
|
||||
}
|
||||
})
|
||||
|
||||
var example2 = new Vue({
|
||||
el: '#example-2',
|
||||
data: {
|
||||
name: 'Vue.js'
|
||||
},
|
||||
methods: {
|
||||
greet: function(event){
|
||||
alert('Hello' + this.name + '!')
|
||||
alert(event.target.tagName)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
var example3 = new Vue({
|
||||
el: '#example-3',
|
||||
methods: {
|
||||
say: function(message){
|
||||
alert(message)
|
||||
},
|
||||
warn: function(message, event) {
|
||||
if (event) event.preventDefault()
|
||||
alert(message)
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue