我正在使用一个函数练习一些模块导出练习,该函数在模块导出中传递了一个返回语句,然后导入到一个新文件中,它告诉我total
没有定义?为什么会这样?
代码:
文件 1:
// Using Async & Await with MODULE EXPORT.
const googleDat = require('../store/google-sheets-api.js');
//passing a let var from a function to another file
let total = googleDat.addVat(100);
console.log(total);
文件 2:
function addVat(price) {
let total = price*1.2
return total
};
module.exports = {
total
};
结果: