English
call_controller
About 189 wordsLess than 1 minute
2025-04-28
This method allows you to quickly call a custom controller function.
FxUI.userDefine.call_controller(apiName: String, parameters: Array)Parameters
| Parameter | Description | Type | Optional Values | Default |
|---|---|---|---|---|
| apiName | apiName of the custom function (required) | string | — | — |
| parameters | Parameters uploaded when calling the API | Array | — | — |
Code Example
This method returns a Promise object, as shown below:
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);
})Usage Tips
If you need to upload many parameters, building parameters can become cumbersome, especially because you also need to set each parameter's type and name, which are easy to get wrong. To simplify this, we recommend the following approach:
- When creating the custom controller, keep only one parameter, and make that parameter of type
Map. - Put multiple parameters into a single
js object, and then upload the data through the API.
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);
})