How to share objects between es6 modules
阿神
阿神 2017-05-19 10:47:01
0
1
626

Use es6 moudle to organize business modules. There are three modules a, b, and c. There is object obj in module a, and export {obj}, both module b and module c are import {obj}, then the b module needs to change the value of obj in the a module;
The traditional way is to directly modify the global variable, and the object exported by the a module in es6 is read-only for the b module. This How to solve the problem (without broadcasting)

阿神
阿神

闭关修行中......

reply all(1)
小葫芦

export出去的对象,其本身的引用是不能改,但是其内部的属性是可以修改的。
exportJust create an object specifically for this type of shared variable.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!