From 040dad37954338e26220c950750f038d18888bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=89?= Date: Sat, 30 Sep 2023 18:45:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=82=A8=E6=9C=AC=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 4 ++++ public/music.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/public/index.html b/public/index.html index 37cb152..147c51e 100644 --- a/public/index.html +++ b/public/index.html @@ -54,6 +54,10 @@ //store.put(item) // 只有在like时才保存到本地 }) }) + musicList.on('add', item => { + console.log('添加音乐', item) + store.put(item) + }) // 初始化客户端列表 const clientList = new ClientList({}) diff --git a/public/music.js b/public/music.js index f5632e9..8fa83ac 100644 --- a/public/music.js +++ b/public/music.js @@ -83,6 +83,10 @@ export default class MusicList { }) ] })) + // 执行回调函数 + if (this.EventListeners['add']) { + this.EventListeners['add'](item) + } } remove(item) { this.ul.removeChild(this.ul.querySelector(`#${item.id}`))