在React Native中如何在Alert.alert中使用foreach

时间:2018-09-02 17:23:26

标签: javascript reactjs for-loop react-native alert

xcopy /C /E /F /R /Y /I "$(SolutionDir)PluginLayer\$(ProjectName)\Areas\StreamVideo\Views" "$(SolutionDir)PresentLayer\Delta.Ecommerce\Plugins\StreamVideo\Areas\StreamVideo\Views"
xcopy /C /E /F /R /Y /I "$(SolutionDir)PluginLayer\$(ProjectName)\Scripts" "$(SolutionDir)PresentLayer\Delta.Ecommerce\Plugins\StreamVideo\Scripts"

2 个答案:

答案 0 :(得分:0)

请使用.map函数而不是.forEach.forEach不返回任何值,因此您只是在数组中传递undefined

考虑以下示例

function openmodal(modalarray) {
  return Alert.alert(
    "Alert Title",
    "My Alert Msg",
    [
      ...modalarray.map(element =>
        ({text: element, onPress: () => console.log('button press')}))
    ],
    { cancelable: false }
  );
}

希望这会有所帮助!

答案 1 :(得分:0)

尝试:

while (!myqueue.empty()) {
    // get a reference to the first element of the queue
    std::string & s = myqueue.front();
    // use it to handle the element
    std::cout << s << endl;
    // remove the first element of the queue; this invalidates all references to it
    myqueue.pop();
    // the reference stored in `s` is invalid now; don't use it any more
}