项目场景:
直接export default pool.promise()出现bug
问题描述
例如: pool.pomise is not a function
file:///E:/dxd/web-pra/vue2/test/api06/db/index.js:10 export default pool.pomise() ^ TypeError: pool.pomise is not a function at file:///E:/dxd/web-pra/vue2/test/api06/db/index.js:10:21 at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:385:24) at async loadESM (node:internal/process/esm_loader:88:5) at async handleMainPromise (node:internal/modules/run_main:61:12)
原因分析:
NPM上的
mysql
库不支持承诺,因此不能与await
一起工作;要导入mysql2才行,可以将async/await
用于mysql调用。
解决方案:
--npm install -