I wrote all the js about the smart contract in a js, and then called it with the js of the page. The callback function does not return a value.
Public js written by oneself
index.js
localhost
I wrote all the js about the smart contract in a js, and then called it with the js of the page. The callback function does not return a value.
Public js written by oneself
index.js
localhost
export?
will
getuser(getuserCallBack());
Change to
getuser(getuserCallBack);
export function getuser(getuserCallBack) {
const result = 123456789;
return getuserCallBack(result);
}
import {getuser} from './eosFunc';
export default function getuser(getuserCallBack) {
const result = 123456789;
return getuserCallBack(result);
}
import getuser from './eosFunc';
first of all, @ he's right
the reason, uh, when we look at it with type system (flow/ts), it's very clear
function getuser(getuserCallBack: function):any {
const result = 123456789;
return getuserCallBack(result);
}
function getuserCallBack(result: any):void {
alert(result);
}
it is obvious that the parameter type accepted by the getuser method should be function, but what you fill in is getuserCallBack (), which means the execution result of the getuserCallBack function, that is, void
so, report an error
can be called after changing the original co-owned function function getuser to var getuser = function, but the public function cannot get its roomn value.