首页 > 解决方案 > 如何转换此箭头函数?

问题描述

我不知道如何将此箭头函数转换为 IE 兼容函数。如果有人可以为此提供解决方案,我真的很感激:

const store = window.WebChat.createStore({}, ({ dispatch }) => next => async action => {
                        if (action.type === 'DIRECT_LINE/POST_ACTIVITY') {
                            // Mocking data to be sent
                            const userId = 'xyz789';
                            const payloadUserContext = action.payload;

                            action = window.simpleUpdateIn(
                                action,
                                ['payload', 'activity', 'channelData'],
                                () => ({
                                    'personId': userId,
                                    'domain': $.urlParam('d'),
                                    'environment': window.location.host,
                                    'userContext': payloadUserContext
                                })
                            )
                        }
                        return next(action);
                    });

标签: javascript

解决方案


只需使用https://babeljs.io/

var store = window.WebChat.createStore({}, function (_ref) {
      var dispatch = _ref.dispatch;
      return function (next) {
        return async function (action) {
          if (action.type === 'DIRECT_LINE/POST_ACTIVITY') {
            // Mocking data to be sent
            var userId = 'xyz789';
            var payloadUserContext = action.payload;
            action = window.simpleUpdateIn(action, ['payload', 'activity', 'channelData'], function () {
              return {
                'personId': userId,
                'domain': $.urlParam('d'),
                'environment': window.location.host,
                'userContext': payloadUserContext
              };
            });
          }

          return next(action);
        };
      };
    });

推荐阅读