通过下面的code可以实现基本功能了,但是有个问题就是每次按/那个input里都会多出一个/,
有没有办法吃掉这个“/”?
created() {
window.addEventListener('keypress', this.onKeyPress);
},
before_destroy() {
window.removeEventListener('keypress', this.onKeyPress);
},
methods: {
onKeyPress(e) {
console.log('KEYPRESS EVENT', e)
if (e.key == '/') {
this.$refs.search_field.focus()
}
}
}
【 在 Madlee 的大作中提到: 】
: 类似该页面,按一下/就把输入焦点放到搜索对话框,
:
https://vuetifyjs.com/zh-Hans/introduction/why-vuetify/: 应该怎么实现?
: ...................
--
修改:Madlee FROM 116.230.161.*
FROM 116.230.161.*