[英]How can I update the values of a global object inside of a function and then access its values with another function in JS?
[英]How can i have an access to style object in another function
我如何在另一個函數中訪問樣式對象。 我有這部分
...
onOk: function() {
var style = new CKEDITOR.style({
element: 'p',
styles: {
//some styles
},
spaceFlag: 'superFlag'
});
editor.applyStyle( style );
},
onShow: function(){
// i want to get here spaceFlag
}
..
似乎您沒有一個函數調用另一個函數。 相反,他們都是兄弟姐妹,都是父級上下文的子級。 因此,在父上下文中定義樣式:
var styleOptions = {
element: 'p',
styles: {
//some styles
},
spaceFlag: 'superFlag'
}, onOk: function() {
var style = new CKEDITOR.style(styleOptions);
editor.applyStyle( style );
},
onShow: function(){
// i want to get here spaceFlag
styleOptions.spaceFlag
},
...
這是一個單獨的代碼段,您可以直接使用它:
function logMe() { var styleOptions = { element: 'p', styles: { //some styles }, spaceFlag: 'superFlag' }; console.log(styleOptions.spaceFlag); } logMe();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.