跳至主要內容

文章

顯示從 2月, 2026 起發佈的文章

xxx xxx

const createGlobalReactive = ( id = "" , prefix = "gr-" ) => {     if ( id [ 0 ] == "#" ) id = id . replace ( '#' , '' );     const _root = id ? document . getElementById ( id ) : document ;     if ( ! _root ) throw new Error ( `The id ' ${ id } ' you give to the globalReactive app is invalid as it can't find the root element!` );     const nodes = { _root };     _root . querySelectorAll ( '*' ). forEach ( n => {         n . classList . forEach ( c => {             if ( c . startsWith ( prefix )) {                 const key = c . replace ( prefix , '' );                 if ( nodes [ key ]){                     nodes [ key ]. push ( n );                 } else {       ...