# FxUI.userDefine.call_controller(apiName, parameters)
This method is convenient for you to quickly call the custom controller function.
# parameter
parameter | illustrate | type | optional value | Defaults |
---|---|---|---|---|
apiName | apiName of the custom function (required) | string | — | — |
parameters | Parameters uploaded by the calling interface | Array | — | — |
# usage
The method returns one Promise object
, an example is as follows:
import FxUI from 'fxui-mobile';
const parameters = [{
type: 'string',
name: 'param1',
value: 123
}];
FxUI.userDefine.call_controller('cus_controller__c', parameters).then((res) => {
if(res.Result.StatusCode == 0) {
console.log(res.Value);
// todo what you want
}
}).catch(err => {
console.log(err);
})
# skills
If you upload a lot of data parameters, parameters
it , especially you need to set the type and name of the parameters, which are prone to errors. To get rid of this trouble, we recommend the following methods:
When creating a custom controller, only one parameter is reserved in the setting parameters, and the type of the parameter is
Map类型
;Store multiple parameters in one
js对象
, and then call the api to upload data
FxUI.userDefine.call_controller('cus_controller__c', [{
type: 'map',
name: 'name',
value: {
param1: '',
param2: '',
param3: '',
...
}
}]).then((res) => {
// todo what you want
}).catch(err => {
console.log(err);
})