我该怎么做?
function myUIEvent() {
var iCheckFcn = "isInFavorites";
var itemSrc = ui.item.find("img").attr("src");
if (eval(iCheckFcn(itemSrc))) { alert("it's a favorite"); }
function isInFavorites(url) { return true; } // returns boolean
我该怎么做?
function myUIEvent() {
var iCheckFcn = "isInFavorites";
var itemSrc = ui.item.find("img").attr("src");
if (eval(iCheckFcn(itemSrc))) { alert("it's a favorite"); }
function isInFavorites(url) { return true; } // returns boolean
eval()
。function myUIEvent() {
var iCheckFcn = isInFavorites;
var itemSrc = ui.item.find("img").attr("src");
if (iCheckFcn(itemSrc)) { alert("it's a favorite"); }
}
eval()
。 - Pointyif ( window[iCheckFcn](itemSrc) ) {
alert("it's a favorite");
};
$rootScope.calculate = function(param1,param2)
{
console.log(param1+param2);
}
var func = '$rootScope.calculate';
eval(func)(1,2); //---> 3