<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
<div id="app">
<input type="text" v-focus>
<input type="text">
</div>
<script type="text/javascript" src="./js/vue.js"></script>
<script>
Vue.directive('focus', {
inserted: function(el) {
//el表示指令锁绑定的元素
el.focus();
}
});
var vm = new Vue({
//绑定的标签
el: '#app',
//自定义按键修饰符
data: {
age: '',
info: '',
msg: ''
},
methods: {
}
});
</script>
</body>
</html>
标签:el,vue,自定义,32,绑定,focus,Vue,指令 From: https://blog.51cto.com/u_15460007/6048834