dte*_*ech 7 javascript qt function tostring qml
似乎可以在JavaScript中获取函数的代码,并且它很简单:
function foo() {...}
foo.toString()
Run Code Online (Sandbox Code Playgroud)
但是,在QML中这样做会让我感到很不舒服 function () { [code] }
那么有没有办法获得这个[code]部分?我也试过,JSON.stringify()但没有做任何好事.
http://doc.qt.io/qt-5/qtqml-javascript-functionlist.html#function-objects
\n\nFunction Properties\n toString()\n apply(thisArg, argArray)\n call(thisArg [, arg1 [, arg2, ...]])\n bind((thisArg [, arg1 [, arg2, \xe2\x80\xa6]])\nRun Code Online (Sandbox Code Playgroud)\n\n对于 JS 函数,QT 不支持获取函数字符串的其他选项。但如果你解释一下你想要它的原因,我们也许能够找到另一个解决方案。
\n