我第一次使用Knockoutjs,并且因为无法在控制台中记录变量而无法调试。我可以看到我的JS在控制台中正确加载,当我输入时:如何将`console.log`与knockout结合使用并订阅Knockoutjs?
Home.TwitterFeedComponent
我看到一个object
返回。我如何将console.log
与knockout和订阅结合使用?
var Home = Home || {};
var inheriting = inheriting || {};
Home.TwitterFeedComponent = function(attributes) {
if (arguments[0] === inheriting)
return;
Home.OnScreenComponent.call(this, attributes);
var component = this;
var recent_tweets = ko.observableArray();
var url = 'https://twitter.com/search.json?callback=?';
this.attributes.twitter_user_handle.subscribe(function(value) {
var twitter_parameters = {
include_entities: true,
include_rts: true,
from: value,
q: value,
count: '3'
}
result = function getTweets(){
$.getJSON(url,twitter_parameters,
function(json) {
console.log(json)
});
}
console.log(twitter_parameters);
});
};
Home.TwitterFeedComponent.prototype = new Home.OnScreenComponent(inheriting);
Home.TwitterFeedComponent.prototype.constructor = Home.TwitterFeedComponent;
你的问题不清楚。你是什么意思,*“将console.log与knockout和subscribe一起使用?”* – 2011-12-15 19:36:32