1. 程式人生 > >js中數據操作的某些思想

js中數據操作的某些思想

import on() 例如 reac ret 直接 pos one win

1,默認數據的復用

寫成function的return形式緩存在變量中,用的時候直接執行fun就行了

例如

有文件text.js裏面的對象是export default ()=>({aa:55,bb:function(){console.log()}})

異步加載之後 緩存在window.componentCfg[type]裏面

import(‘./text‘).then(e=>e.default).then(e=>{

window.componentCfg[‘text‘]=e;

})

使用時就不用考慮深度拷貝,串引用等問題;

window.componentCfg[‘text

‘]();

react組件的異步加載也是如此。

js中數據操作的某些思想