それで、私はかなり複雑なプラグインを構築していて、思わぬ障害に遭遇しました。(これは私が学習する方法なので、思わぬ障害が発生することはありません...) 私のコードは次のようになります。
資料1
if( !window.TextEdit ){
var TextEdit = {"version": "1.0"};
}
TextEdit.edit = function(context, options) {
var self = this;
self.context = context;
self.buttonDef = {
bold: {
class: 'bold',
command: 'bold',
icon: 'bold',
type: 'checkbox',
label: ''
},
italic: {
class: 'italic',
command: 'italic',
icon: 'italic',
type: 'checkbox',
label: ''
},
underline: {
class: 'underline',
command: 'underline',
icon: 'underline',
type: 'checkbox',
label: ''
}
}
self.init();
}
資料2
if( !window.TextEdit.imageload ){
TextEdit.imageload = {"version": "1.0"};
}
TextEdit.imageload = function() {
var self = this;
self.editor = TextEdit;
self.init();
}
TextEdit.imageload.prototype = {
init: function() {
var self = this;
console.log(self.buttonDef);
$('.tdt-btn-addimage').click(function() {
});
},
create: function() {
},
destroy: function() {
}
}
new TextEdit.imageload();
したがって、ドキュメント 2 を使用して、ドキュメント 1 の変数 self.buttonDef にアクセスしたいと考えています。ドキュメント 1 の関数には問題なくアクセスできますが、変数にはアクセスできません。
私が探しているのはbuttonDef
、のプロパティを作成する方法ですTextEdit
。