module.js是我的流类型模块的地方,我试图通过从节点模块" module.js"中导入代码来在我的form.js中应用代码。但显示错误未捕获错误:找不到模块" ./ src / module.js"。我不确定错误来自哪里,因为这是我得到的唯一错误。
module.js
function capitalizeFirstLetter(data: string) {
return data.charAt(0).toUpperCase() + data.slice(1);
}
function titleize (data: String) {
if (data === null || data === undefined) {
return "";
}
let cleanTitle = data.replace(/[ \-_]+/g, " ");
let words = cleanTitle.replace(/([A-Z])/g, " $&").trim().split(" ");
let capitalizedWords = words.map(word => capitalizeFirstLetter(word));
return capitalizedWords.join(" ").toString();
}
module.exports = {
titleize: titleize
};
form.js
import app from "my-app";
/* code here */
render() {
console.log(app.titleize("sample log"));
}