線上書籍

Home

111網頁前端設計工程師培訓班

一、物件設值:


let obj = {};

obj['title'] = "育將電腦工作室";

obj['content'] = "123";

二、物件取值:

obj[title] 

obj.title

/* ========================== 渲染 render('index', {content: '網頁內容'}, '首頁'); ============================*/ function render(file, argsObject, title){ var tmp = HtmlService.createTemplateFromFile(file); if(argsObject){ for(i in argsObject){ tmp[i] = argsObject[i]; } } return tmp.evaluate().setTitle(title).setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL).addMetaTag('viewport', 'width=device-width, initial-scale=1'); } /*====================================== 渲染樣版&子樣版 file: 樣版(主檔名即可) argsObject: 參數 title: 有值=>主樣板 空值=>子樣板 ======================================*/ static render(file, argsObject, title=''){ let tmp = HtmlService.createTemplateFromFile(file); if(argsObject){ for(let i in argsObject){ tmp[i] = argsObject[i]; } } if(title){ return tmp.evaluate().setTitle(title).setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL).addMetaTag('viewport', 'width=device-width, initial-scale=1'); }else{ return tmp.evaluate().getContent(); } }