由于公司的设计偏爱iview的这种设计风格,所以在vue的道路上与iview形影不离
AutoComplete
最开始发现有问题是偶然的从这个组件开始的,但其实是一个select相关操作的问题,不过跟使用的机器有关。
可能不同的机器对键盘的码的识别不一样,导致在某些电脑上无法使用回车、上下箭头、tab、删除键等。
最后在全局统一定义键盘码才得以解决,keys.js,Vue.use(keys)
const hasKeybordEvent = () => (
typeof KeyboardEvent === 'function' &&
(new KeyboardEvent(null)).key
)
const codeName = {
8: 'Backspace',
9: 'Tab',
13: 'Enter',
27: 'Escape',
38: 'ArrowUp',
40: 'ArrowDown'
}
export default {
install (Vue, options) {
if (this.installed || hasKeybordEvent()) return
this.installed = true
// let { keyCodes } = options
Object.defineProperties(KeyboardEvent.prototype, {
key: {
get () {
return this.code || codeName[this.keyCode]
},
set () {