使用變量從一個文件,所以,我建立一個相當複雜的插件,跑進一個障礙。 (這是我如何學習的,所以斷枝都不錯......)我的代碼看起來類似於以下內容:的javascript:在其他
文件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();
因此,使用Document 2我想訪問文檔1中的變量self.buttonDef。我可以很好地訪問Document 1中的函數,但不能訪問變量。
我所尋找的是如何讓buttonDef
的TextEdit
的屬性。
謝謝:)它的工作 – watzon