[英]ReactJS how to call a component function from another function on the same file?
[英]How to call another's file function in a module function on ReactJS
我想調用寫在apiGet.js文件中的這些函數:
export let apiGet = () => {
return 'File One';
}
它在另一個名為brand.js文件的模塊上調用,這是代碼:
require("../actions/apiGet.js");
const sendGetRequest = () => {
console.log(apiGet());
};
module.exports = sendGetRequest();
執行后,報錯:
Uncaught ReferenceError: apiGet is not defined
如何解決這個問題?
import { apiGet } from './actions';
這樣的事情應該有效。 當然,路徑將根據操作的位置而變化。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.