<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue.js"></script>
</head>
<body>
<div id="app">
<input type="text" v-focus>
</div>
<script>
new Vue({
el:'#app',
directives:{
focus:{
// 指令的定义
inserted: function (el) {
el.focus()
}
}
}
})
</script>
</body>
</html>
网友评论