<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Vue</title>
<script src='../js/vue.js'></script>
</head>
<body>
<div id='app'>
<h2>{{n}}</h2>
<h2><span v-big="n"></span></h2>
<button @click="n++">n+1</button>
<input type="text" v-finput="n">
</div>
<script>
new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!',
n: 1,
},
directives: {
// 指令 绑定时 和 模板在重新解析时被调用
big(el, binding) {
console.log("big");
el.innerText = binding.value * 10;
},
finput: {
// 绑定时
bind(el, binding) {
console.log("binding");
el.value = binding.value
},
// 生成到界面时
inserted(el, binding) {
console.log("inserted");
el.focus()
},
// 更像时
update(el, binding) {
el.value = binding.value
console.log("updata");
},
}
}
})
</script>
</body>
</html>
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
喜欢就支持一下吧