比如下面 script.js
和 common.js
在同一目录下。
const Tool = require('common.js');
module.exports = async (params) => {
console.log(Tool.getMonth());
};
module.exports = {
getMonth: function (date) {
if (!date) date = new Date();
const month = date.getMonth() + 1;
if (month < 10) return '0' + month;
return month;
}
};
使用 Quickadd 运行脚本 script.js
后会报错: