js中renderTo是什么意思
js中renderTo是什么意思?
料青山看我應(yīng)如是
2019-02-05 09:07:48
TA貢獻(xiàn)1848條經(jīng)驗 獲得超10個贊
12345678910111213141516171819202122232425262728293031323334353637 | renderto的作用:指明控件要渲染的節(jié)點的,每一個控件都要指明該控件需要渲染到哪一個DOM節(jié)點。 renderTo的使用: 1、可以有el配置選項。 2、如果有el配置選項,則其指向的el元素充當(dāng)了模板,并且必須存在。 3、renderTo所指向的el元素將作為對象渲染的入口,即render所產(chǎn)生的html代碼將作為renderTo所指向的el元素的子節(jié)點。 4、如果有el配置選項,那么render會將el配置選項所指向的el元素作為模板然后產(chǎn)生html代碼作為renderTo所指向的el元素的子節(jié)點。 5、示例代碼: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " < html > < head > < meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" > < title >applyTo與renderTo的區(qū)別</ title > < link rel = "stylesheet" type = "text/css" href = "../scripts/ext/resources/css/ext-all.css" /> < script type = "text/javascript" src = "../scripts/ext/adapter/ext/ext-base.js" ></ script > < script type = "text/javascript" src = "../scripts/ext/ext-all.js" ></ script > < script type = "text/javascript" > Ext.onReady(function(){ var _panel = new Ext.Panel({ title:"個人信息", //title信息 width:300, //定義寬 height:300, //定義高 frame:true, el:"elId", renderTo:"appConId" //renderTo 的ID }); }); </ script > </ head > < body > < div id = "appId" style = "padding:30px;width:500px;height:400px;background-color: blue;" > < div id = "appConId" style = "width:400px;height:400px;background-color:green;" ></ div > </ div > < div id = "elId" style = "width:500px;height:400px;background-color:red;" > </ div > </ body > </ html > |
舉報