- input 身上的事件( focus 、 blur 、 change 、input)
- 事件有几种绑定形式
- js中绑定
var input = document.querySelector( ’ input ’ )
input.oninput = function ( ) { }
DOM2级事件 事件监听 - html结构中绑定
function load ( ) { }
vue中事件绑定形式选择2
- js中绑定
- 事件包含哪几个部分?
事件源、 事件类型、 事件处理程序 - vue中事件格式: ( 举例 : )
<div v-on:eventType = '事件处理程序'></div>
单向数据绑定实现双向数据绑定效果 案例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> 指令 </title>
</head>
<body>
<div id="app">
<input type="text" :value="msg" v-on:input="change">
<!-- 简写 -->
<input type="text" :value="msg" @input="change">
</div>
</body>
<script src="../../lib/vue.js"></script>
<script>
new Vue({
el: '#app', // 挂载
data: {
msg: '真的很帅'
},
methods: {
//事件处理程序
change: function (e) {
this.msg = e.target.value
}
}
})
</script>
</html>