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