我想从gulp切换到webpack,但是我遇到了一些我无法解决的问题。
首先,我要创建一个编辑器,然后用gulp实例化编辑器:
new RSMDE({
variables: vars,
element: document.getElementById('mdediror'),
initialValue:
'# EasyMDE \n Go ahead, play around with the editor! Be sure to check out **bold**, *italic* and ~~strikethrough~~ styling, [links](https://google.com) and all the other features. You can type the Markdown syntax, use the toolbar, or use shortcuts like `ctrl-b` or `cmd-b`.',
});
在我的编辑器文件中,我曾经有这个:
// Importing libraries here.
function RSMDE(options) {
// Handle options parameter
options = options || {};
// Used later to refer to it"s parent
options.parent = this;
var autoDownload = true;
// Editor code goes here
....
}
module.exports = RSMDE;
但是现在我想切换到webpack,但是在编译时遇到了一个问题。我收到此错误:
Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
我已将module.exports = RSMDE;
更改为export default RSMDE
的问题消失了,但是当我将function RSMDE(options){}
更改为class RSMDE
时,代码将如下所示:
// Importing libraries here.
class RSMDE {
// Handle options parameter
options = options || {};
// Used later to refer to it"s parent
options.parent = this;
var autoDownload = true;
// Editor code goes here
....
}
export default RSMDE;
但是现在我得到了另一个错误:
Unexpected token
=>此错误位于options.parent