<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>directive</title>
<script src="../vuejs/vue.min-1.0.28.js"></script>
</head>
<body>
<div id='app'>
<input type="text" name="" v-focus >
</div>
<script type="text/javascript">
Vue.directive('focus',function(){
console.info(this.el);
var ele = this.el;
ele.focus();
});
new Vue({
el:'#app'
});
</script>
</body>
</html>
vue 自定义指令
最新推荐文章于 2024-04-24 21:31:50 发布