收藏
回答

windows下开发工具Function.apply()函数undefined?

如题,Windows下小程序开发工具中, Function.apply()函数undefined,打印无果,无法使用。这东西折腾了我五天······

回答关注问题邀请回答
收藏

2 个回答

  • 疯狂的小辣椒
    疯狂的小辣椒
    2019-07-31

    你好,测试未复现,麻烦提供出现问题的工具的版本类型、版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

    2019-07-31
    有用
    回复 5
    • Krichevskoy_杨墨
      Krichevskoy_杨墨
      2019-07-31
      function lambda(l) { var fn = l.match(/\((.*)\)\s*=>\s*(.*)/); var p = []; var b = ""; console.log(fn) if (fn.length > 0) { fn.shift(); } if (fn.length > 0) { b = fn.pop();} if (fn.length > 0) { p = fn.pop() .replace(/^\s*|\s(?=\s)|\s*$|,/g, '').split(' '); console.log("p = ", p); } console.log(fn) fn = ((! /\s*return\s+/.test(b)) ? "return " : "") + b; console.log(fn) p.push(fn); console.log("p2 = ", p); try { return Function.apply({}, p); } catch (e) { return null; } } Array.prototype.where = function (f) { var fn = f; if (typeof f == "string") { console.log('001'); if ((fn = lambda(fn)) === null) { console.log("Syntax error in lambda string: " + f); return; console.log('null') } var res = []; var l = this.length; var p = [0, 0, res]; for (var i = 1; i < arguments.length; i++) { p.push(arguments[i]); console.log('3')} console.log(p) for (var i = 0; i < l; i++) { if (typeof this[i] == "undefined") { continue; console.log('4')} p[0] = this[i]; console.log(p) p[1] = i; console.log(p) if (!!fn.apply(this, p)) { res.push(this[i]);} } console.log('成功!') return res; } } var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; console.log(Array.prototype.where); console.log(Array.prototype.slice); a.where('( ) => true');
      2019-07-31
      回复
    • 疯狂的小辣椒
      疯狂的小辣椒
      2019-07-31回复Krichevskoy_杨墨

      提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

      2019-07-31
      回复
    • Krichevskoy_杨墨
      Krichevskoy_杨墨
      2019-07-31回复疯狂的小辣椒
      https://developers.weixin.qq.com/s/JYWM9gmV7OaW
      2019-07-31
      回复
    • 疯狂的小辣椒
      疯狂的小辣椒
      2019-07-31回复Krichevskoy_杨墨

      你console.log(fn)试试


      2019-07-31
      回复
    • Krichevskoy_杨墨
      Krichevskoy_杨墨
      2019-08-01回复疯狂的小辣椒
      嗯嗯嗯,有问题。
      2019-08-01
      回复
  • 铭锋科技
    铭锋科技
    2019-07-31

    看下这个对你有没有帮助

    https://developers.weixin.qq.com/miniprogram/dev/framework/quickstart/#%E5%B0%8F%E7%A8%8B%E5%BA%8F%E6%8A%80%E6%9C%AF%E5%8F%91%E5%B1%95%E5%8F%B2

    2019-07-31
    有用
    回复 1
    • Krichevskoy_杨墨
      Krichevskoy_杨墨
      2019-07-31
      大大,没有用~您可以去试试,真的undefined···不知道官方会怎么说
      2019-07-31
      回复
登录 后发表内容