输入框变成空之后,我还想鼠标 focus,应该怎么做?
输入框变成空之后,我还想鼠标 focus,应该怎么做?
输入框变成空之后,我还想鼠标 focus,应该怎么做?
2018-05-28
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="https://cdn.jsdelivr.net/npm/vue@2.5.17/dist/vue.js"></script> </head> <body> <div id="root"> <div> <input v-model="inputValue" :autofocus="is_focus"/> <button @click="handleClick">提交</button> </div> <ul> <li v-for="item of list" :key="item">{{item}}</li> </ul> </div> <script> new Vue({ el: '#root', data: { list: ['a', 'b', 'c'], inputValue: '', is_focus: '', }, methods: { handleClick: function () { this.list.push(this.inputValue); this.inputValue = ''; this.is_focus = true; } } }) </script> </body> </html>
举报