我从 Trumbowyg 插件创建组件到 vue.js 库。我需要在这个漂亮的所见即所得编辑器中添加两种方式绑定(bind)。 如何重写buildEditor()方法? 这个方法是私有(private)的。如何正确地做到这一点?
<script>
jQuery.trumbowyg = {
// options object
};
(function (navigator, window, document, $, undefined) {
$.fn.trumbowyg = function (options, params) {
// ... code ...
$(this).data('trumbowyg', new Trumbowyg(this, options));
// ... code ...
};
var Trumbowyg = function (editorElem, o) {
var t = this;
// ... code ...
t.init();
};
Trumbowyg.prototype = {
init: function () {
var t = this;
t.buildEditor();
// ... code ...
},
buildEditor: function () {
// i need rewrite this method
}
// code for otner method
};
})(navigator, window, document, jQuery);
// -------------------------------------
// other file. I want init this plugin
// here do need to rewrite buildEditor() method? What best way to do this?
$('.selector').trumbowyg();
最佳答案
如果此插件不返回“Trumbowyg”变量,则不可能。我建议 fork 此插件并使用您的设置创建您自己的版本。
关于javascript - 如何在javascript中重新定义私有(private)方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36502994/