您好我正在使用api但是我应该为它做一个补丁
Songapi.prototype.goPlaySong=Songapi.prototype.goPlaySong.toString().replace('["universal","emi","warner"]) !== -1','false');
不起作用 也尝试了
Songapi.prototype.goPlaySong=Function(Songapi.prototype.goPlaySong.toString().replace('["universal","emi","warner"]) !== -1','false'));
或
Songapi.prototype.goPlaySong=eval(Songapi.prototype.goPlaySong.toString().replace('["universal","emi","warner"]) !== -1','false'));
仍然无法做到这一点?
答案 0 :(得分:3)
SongApi
是constructor
a.k.a一个班级。
function inherits(child, parent) {
function temp() {};
temp.prototype = parent.prototype;
child.prototype = new temp();
child.prototype.constructor = child;
};
var CustomizedApi = function() {
SongApi.call(this);
};
inherits(CustomizedApi, Songapi);
// or use Object.create for inheritance.
CustomizedApi.prototype = Object.create(SongApi.prototype);
/**
* @override
*/
CustomizedApi.prototype.goPlaySong = function() {
// override with whatever you want.
};
var api = new CustomizedApi;
api.goPlaySong();
答案 1 :(得分:1)
尝试:
eval('var code = ' + Songapi.prototype.goPlaySong.toString().replace('["universal","emi","warner"]) !== -1','false'));
Songapi.prototype.goPlaySong = code;
但这绝对是肮脏的。
答案 2 :(得分:0)
var newgoPlaySong=Songapi.prototype.goPlaySong.toString().replace('$.inArray(response.provider,["universal","emi","warner"]) !== -1','false');
eval('Songapi.prototype.goPlaySong = '+gecicigoPlaySong+';');
感谢