@memberof Util
*/
static storage() {
let ls = window.sessionStorage || window.localStorage;
if (!ls) {
return null
};
return {
set: function (key, value) {
ls.setItem(key, Util.serialize(value));
},
get: function (key) {
return Util.deserialize(ls.getItem(key));
},
remove: function (key) {
ls.removeItem(key);
},
clear: function () {
ls.clear();
}
}
}
}
报错:util.js:178 Uncaught ReferenceError: doc is not defined
babel 官网 试了下 需要 babel-preset-stage-2 支持。
修改fis-conf.js
postprocessor: function (content, file, settings) {
let babel = require('babel-core');
let preset2015 = require('babel-preset-es2015');
let presetstage2 = require('babel-preset-stage-2');
let react = require('babel-preset-react');
settings = fis.util.extend({
presets: [
preset2015,
presetstage2,
react
]
}, settings);
// 添加 jsx 的 html 语言能力处理
if (fis.compile.partial && file.ext === '.jsx') {
content = fis.compile.partial(content, file, {
ext: '.html',
isHtmlLike: true
});
}
let result = babel.transform(content, settings);
return result.code;
},
修改 node_module 下的插件文件
var babel = require('babel-core');
var preset2015 = require('babel-preset-es2015');
// var presetstage3 = require('babel-preset-stage-3');
var presetstage2 = require('babel-preset-stage-2');
var react = require('babel-preset-react');
例如: export class Util { doc = window.document; constructor() {} /**
@memberof Util */ static serialize(value) { if (typeof value === 'string') { return value; } return JSON.stringify(value); }
/**
babel 官网 试了下 需要 babel-preset-stage-2 支持。
修改fis-conf.js
修改 node_module 下的插件文件 var babel = require('babel-core'); var preset2015 = require('babel-preset-es2015'); // var presetstage3 = require('babel-preset-stage-3'); var presetstage2 = require('babel-preset-stage-2'); var react = require('babel-preset-react');
module.exports = function (content, file, conf) { // 添加 useBabel 配置项,如果 useBabel 为 false 则不进行编译 if (file.useBabel === false) { return content; }
};
都无法编译。