0
我有一個用Dojo編寫的基本小部件,它使用DTL來打印幾個變量。但是,如果其中一個變量爲空,則會導致錯誤(str爲空)。有沒有可能解決或繞過這個錯誤?我想它打印只是一個空字符串...在dojo中打印空值時出錯dtl
我使用道場1.9.0在Firefox 24
我有一個用Dojo編寫的基本小部件,它使用DTL來打印幾個變量。但是,如果其中一個變量爲空,則會導致錯誤(str爲空)。有沒有可能解決或繞過這個錯誤?我想它打印只是一個空字符串...在dojo中打印空值時出錯dtl
我使用道場1.9.0在Firefox 24
我有同樣的問題,我結束了創建一個補丁因此這將不會發生。 這將返回字符串null。如果你想讓它返回空的sting取消註釋str =「」;
//Patch for DTL so it wont fail everytime there is a null value in JSON.
require([ "dojox/dtl/_base"],function(){
dojox.dtl._VarNode.prototype.render = function(context, buffer){
var str = this.contents.resolve(context);
if(str){
if(!str.safe){
str = dojox.dtl._base.escape("" + str);
}
}else{
writeLog("=====Value was Null::" + this.contents.key);
//str="";
}
return buffer.concat(str);
};
});
歡迎來到StackOverflow。你有一些我們可以看到的代碼嗎?如果沒有代碼,我們很難幫助你。 – sircapsalot