未捕获的类型错误:data.some 不是函数

10 *_*uge 7 javascript magento typeerror

我正在尝试找出在 Magento 电子商务扩展中收到的 JS 错误,我为此付出了很多钱,但他们一直缺乏解决此问题的支持。错误会导致页面加载时出现永远不会消失的厄运。

以下是我在开发者控制台中收到的错误:

Uncaught TypeError: data.some is not a function
at findFirst (select.js:67)
at UiClass.normalizeData (select.js:193)
at UiClass.normalizeData (wrapper.js:109)
at UiClass.getInitialValue (abstract.js:200)
at UiClass.setInitialValue (abstract.js:143)
at UiClass._super (wrapper.js:106)
at UiClass.setInitialValue (select.js:302)
at UiClass.setInitialValue (wrapper.js:109)
at UiClass.initialize (abstract.js:70)
at UiClass.initialize (wrapper.js:109)
Run Code Online (Sandbox Code Playgroud)

这是 select.js data.some(function (node) {的第 67 行的代码部分,错误引用:

/**
 * Recursively loops over data to find non-undefined, non-array value
 *
 * @param  {Array} data
 * @return {*} - first non-undefined value in array
 */
function findFirst(data) {
    var value;

    data.some(function (node) {
        value = node.value;

        if (Array.isArray(value)) {
            value = findFirst(value);
        }

        return !_.isUndefined(value);
    });

    return value;
}
Run Code Online (Sandbox Code Playgroud)

我希望这只是某种打字错误,我可以自己修复吗?

预先感谢您的任何帮助。

PS 我是一个编码新手。

Kev*_*vez 2

在 Magento 2.1.8 中,删除了一个可能影响某些扩展的方法 - 它影响了我们的 getOptionArray()。

要在我们的扩展中修复它:Ui/DataProvider/Product/Form/Modifier/FixedSelectionType.php

'options' => FixedType::getOptionArray(),
Run Code Online (Sandbox Code Playgroud)

变成:

'options' => FixedType::getOptionsArray(),
Run Code Online (Sandbox Code Playgroud)

并在 model/attribute 文件夹中添加此方法,在我们的示例中,完整路径为:Model/Attribute/Sources/FixedType.php

在公共函数 getalloptions() 方法上方添加以下内容:

public static function getOptionsArray()
 {
     $result = [];

     foreach (self::getOptionArray() as $index => $value) {
         $result[] = ['value' => $index, 'label' => $value];
     }

     return $result;
 }
Run Code Online (Sandbox Code Playgroud)