Closed adammoroff closed 5 years ago
Resolved.
这个问题的源码是这样的
filterMatch: {
type: Function,
default: (name, chunk, at) => {
// match at lower-case
return name.toLowerCase()
.indexOf(chunk.toLowerCase()) > -1
}
}
也就是读不到name值,是因为这个方式直接去读了members数组的子元素作为name值,但是这里给的member数组的子元素是一个对象,所以会报错。 解决方案是 输出memvers: ['wamoumou','zhangsan','lisi']这样的格式
filterMatch 这个prop给的默认函数 确实是直接用name比对哈:
https://github.com/fritx/vue-at/blob/eae5f4cafdcb0f8c17c606b435527e49e4109d2a/src/At.vue#L321-L324
但比对之前,name 都是经过 itemName() 转换过的, 兼容了 members 为对象数组和字符串数组这两种情况, (如果是对象数组,需要同时提供 nameKey 这个prop):
https://github.com/fritx/vue-at/blob/eae5f4cafdcb0f8c17c606b435527e49e4109d2a/src/At.vue#L146-L149
Hi @fritx I was wondering if you could help me. Im using vue-at 2.x and when entering the '@' symbol I get the following error message:
Uncaught TypeError: t.toLowerCase is not a function at default (vue-at.js?a1f5:1) at eval (vue-at.js?a1f5:1) at Array.filter ()
at VueComponent.handleInput (vue-at.js?a1f5:1)
at input (vue-at.js?a1f5:1)
at invoker (vue.runtime.esm.js?2b0e:2023)
at HTMLDivElement.fn._withTask.fn._withTask (vue.runtime.esm.js?2b0e:1822)
HTML
JS: