[英]How to call another's file function in a module function on ReactJS
I want to call these function written on apiGet.js file:我想调用写在apiGet.js文件中的这些函数:
export let apiGet = () => {
return 'File One';
}
It's called on another module named brand.js file, this is the code:它在另一个名为brand.js文件的模块上调用,这是代码:
require("../actions/apiGet.js");
const sendGetRequest = () => {
console.log(apiGet());
};
module.exports = sendGetRequest();
After executed, there is an error:执行后,报错:
Uncaught ReferenceError: apiGet is not defined
How to solve this?如何解决这个问题?
import { apiGet } from './actions';
Something like that should work.这样的事情应该有效。 The path will change depending on where actions is of course.
当然,路径将根据操作的位置而变化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.