此處以項(xiàng)目中登錄組件為例說(shuō)明
- 新建組件
在 public/wap/first/zsff/components 目錄下新建文件夾,例如新建 base-login 文件夾,然后在 base-login 文件夾下新建index.html,
index.css,index.js 文件。
index.html 寫(xiě)html模版內(nèi)容
index.css 寫(xiě)style樣式內(nèi)容
index.js 寫(xiě)javascript內(nèi)容
- 使用組件
使用組件遵循,先導(dǎo)入,再注冊(cè),最后使用順序。
例如個(gè)人中心頁(yè)面 application/wap/view/first/my/index.html。先使用require導(dǎo)入base-login組件,然后再components中注冊(cè)。組件導(dǎo)入使用了require.js庫(kù)。