Object(...) is not a function,看到这个报错我可以百分百肯定的告诉你是你的函数有问题。浏览器找不到相对应的函数,快去看看你是不是在引入函数后使用的时候出错或者未定义这个函数吧!
import { tranListToTreeData } from '@/utils'
async getDepartments() {
this.showTree = true
// this.loading = true
const { depts } = await getDepartments()
// depts是数组 但不是树形
this.treeData = tranListToTreeData(depts, '')
console.log(this.treeData)
// this.loading = false
}
// 例如:这两个tranListToTreeData函数名称必须一样。
最后就是如果有小伙伴在使用 import * as xxx from '@/xxxx' 这个语法后,想去 main.js 中循环遍历匹配每一项后通过 Object.keys 这个方法来注册一些事件的时候。一定要记得这以下两个坑!!!
0:注册事件的时候结尾千万不要加s,
1: key不需要引号
如图:
Object.keys(directives).forEach(key => { // 注册自定义指令
Vue.directive(key, directives[key])
})
Object.keys(filters).forEach(key => {
// 注册过滤器
Vue.filter(key, filters[key])
})
// directive 和 filter千万不要加s
// key不需要''