Immutable is an unchangeable data set developed by Facebook. Immutable data cannot be modified once it is created. application development is simpler. function-based programming technology, such as inertia evaluation, can be used. ImmutableJS provides an inert Sequence that allows efficient queue method chains, similar to... Immutable is an Immutable data set developed by Facebook. Immutable data cannot be modified once it is created. application development is simpler. function-based programming technology, such as inertia evaluation, can be used. Immutable JS provides an inert Sequence that allows efficient queue method chains, such as map and filter, without creating intermediate representatives. Immutable provides Sequence, Range, Repeat, Map, OrderedMap, Set, and a sparse Vector through the inert queue and hash ING.
The applet cannot directly use require ('immutable. js') for calling. you need to modify the downloaded immutable code before using it.
Cause analysis
Immutable uses UMD modular specifications
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Immutable = factory());}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice;....}));
The implementation of UMD is very simple. First, determine whether the Node. js (CommonJS) module specification is supported. if so, use the Node. js (CommonJS) method to load the module. Determine whether AMD is supported, and use AMD to load modules. If neither of the first two does exist, the module is published to the global environment.
Both exports and module must be defined to load modules in CommonJS. Through the test, the program running environment exports and module are not defined.
Solution
Modify the Immutable code, comment out the export statement of the original module, and use module. exports = factory () to force export
(function(global, factory) { /* typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Immutable = factory()); */ module.exports = factory();}(this, function() {Use Immutable. js
// Index. jsvar Immutable = require ('.. /.. /libs/immutable. modified. js '); // Obtain the application instance var app = getApp (); Page ({onLoad: function () {// console. log ('onload'); var that = this; var lines = []; lines. push ("var map1 = Immutable. map ({a: 1, B: 2, c: 3}); "); var map1 = Immutable. map ({a: 1, B: 2, c: 3}); lines. push ("var map2 = map1.set ('B', 50);"); var map2 = map1.set ('B', 50); lines. push ("map1.get ('B');"); lines. push (map1.get ('B'); lines. push ("map2.get ('B');"); lines. push (map2.get ('B'); this. setData ({text: lines. join ('\ n ')})}})