我有一些看起来像这样的 Spotify 应用程序代码:
require(['$api/models', '$views/list#List', '$api/search#Search'], function(models, List, Search) {
var testList = function(){
var album = models.Album.fromURI('spotify:album:6iBEe3qEjdIRz38swH7jT0');
console.log(album);
var list = List.forAlbum(album);
document.body.appendChild(list.node);
list.init();
var al2 = models.Album.fromURI('spotify:album:5fTBlCZFI4zYOdJn1NrLgt');
list.setItem(al2);
};
testList();
});
当我在我的 Spotify 应用程序中运行它时,我收到以下错误:
Uncaught TypeError: Cannot read property 'null' of undefined core.js:4
如果有帮助,这是 List.setItem() 的源代码:
function (a,b){if(!this.destroyed){var c=
this,d=a instanceof f.Collection;b&&(this.options.context=b);!this.lists&&d?(this.model.setCollection(a),this.dispatchEvent({type:"set-item",item:a}),this._resetContextGroup(),this.refresh()):(this.lists&&this._callForEachList("destroy"),this.destroy(),this.addEventListener("list-init",function g(){c.removeEventListener("list-init",g);c.dispatchEvent({type:"set-item",item:a});this._resetContextGroup();c._oldParentNode&&c._oldParentNode.appendChild(c.node);this.init()}),d?this._init(a):this._loadItem(a),
this.destroyed=!1)}}
我正在使用 API 版本 1.0.0 和视图 1.35.0。List 类的文档在这里:https ://developer.spotify.com/docs/apps/views/1.0/list-list.html 任何帮助表示赞赏!