Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mock.js 1.0.0报错 @pick() #90

@Bosn

Description

@Bosn

Mock规则

确定旧版本Mock.js可以正常产出数据,更新到v1.0.0后报错

{
    "arr": [{
        "val2": "@pick(\'haha\', heihei\', hoho\')",
        "val": function() {
            var window = function() {
                return this;
            }();

            function geneVal(key) {
                var o = __rap__context__[key];
                var arr = o.arr;
                return arr[o.index++ % arr.length];
            }
            if (!window.__rap__context__) {
                window.__rap__context__ = {};
            }
            var orderCmd = "$order(\'\u7b80\u4ecb\u7b80\u4ecb\u7b80\u4ecb\u7b80\u4ecb\u7b80\u4ecb\u7b80\u4ecb\',\'JavaScript\u9ad8\u7ea7\u7a0b\u5e8f\u8bbe\u8ba1\',\'JavaScript\u6743\u5a01\u6307\u5357\',\'\u56fe\u89e3HTTP\',\'bbbbbbbbbbbbbbb\',\'\u554a\u554a\u554a\u554a\u554a\u554a\u554a\u554a\u554a\u554a\')";
            var orderArr = eval('[' + orderCmd.substring(7, orderCmd.length - 1) + ']');
            var key = '10000';
            if (!__rap__context__[key]) {
                __rap__context__[key] = {
                    arr: orderArr,
                    index: 0
                };
            }
            return geneVal(key);
        }
    }]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions