第一步 項(xiàng)目配置一、編寫app.json對(duì)整個(gè)項(xiàng)目的公共配置1、pages:配置頁面路徑(必須),列出所有的頁面的路徑,所有存在的頁面都需要在此寫出,否則在頁面跳轉(zhuǎn)的時(shí)候會(huì)報(bào)出找不 ...
對(duì)整個(gè)項(xiàng)目的公共配置
1、pages:配置頁面路徑(必須),列出所有的頁面的路徑,所有存在的頁面都需要在此寫出,否則在頁面跳轉(zhuǎn)的時(shí)候會(huì)報(bào)出找不到頁面的錯(cuò)誤
2、window:窗口配置,配置導(dǎo)航及窗口的背景色和文字顏色,還有導(dǎo)航文字和是否允許窗口進(jìn)行下拉刷新
3、tabBar:tab欄配置,配置tab欄背景色及出現(xiàn)位置,上邊框的顏色(目前只支持黑或白),文字顏色及文字選中顏色,最核心的配置是list即tab欄的列表,官方規(guī)定最少2個(gè),最多5個(gè),每個(gè)列表項(xiàng)目可配置頁面路徑、文字、圖標(biāo)及選中時(shí)圖標(biāo)的地址
4、network:網(wǎng)絡(luò)配置,配置網(wǎng)絡(luò)請(qǐng)求、上傳下載文件、socket連接的超時(shí)時(shí)間
5、debug:調(diào)試模式,建議開發(fā)時(shí)開啟(true),可以看到頁面注冊(cè)、頁面跳轉(zhuǎn)及數(shù)據(jù)初始化的信息,另外報(bào)錯(cuò)的錯(cuò)誤信息也會(huì)比較詳細(xì)
{"pages": ["pages/popular/popular","pages/coming/coming","pages/top/top","pages/search/search","pages/filmDetail/filmDetail","pages/personDetail/personDetail","pages/searchResult/searchResult"],"window": {"navigationBarBackgroundColor": "#47a86c","navigationBarTextStyle": "white","navigationBarTitleText": "電影推薦","backgroundColor": "#fff","backgroundTextStyle": "dark"},"tabBar": {"color": "#686868","selectedColor": "#47a86c","backgroundColor": "#ffffff","borderStyle": "white","list": [{"pagePath": "pages/popular/popular","iconPath": "dist/images/popular_icon.png","selectedIconPath": "dist/images/popular_active_icon.png","text": "熱映"}, {"pagePath": "pages/coming/coming","iconPath": "dist/images/coming_icon.png","selectedIconPath": "dist/images/coming_active_icon.png","text": "待映"},{"pagePath": "pages/search/search","iconPath": "dist/images/search_icon.png","selectedIconPath": "dist/images/search_active_icon.png","text": "搜索"},{"pagePath": "pages/top/top","iconPath": "dist/images/top_icon.png","selectedIconPath": "dist/images/top_active_icon.png","text": "口碑"}]},"networkTimeout": {"request": 10000,"downloadFile": 10000},"debug": true}根據(jù)UI圖,提取組件和公共樣式/腳本,以及page的目錄
<template name="filmList"><block wx:if="{{showLoading}}"><view class="loading">玩命加載中…</view></block><block wx:else><scroll-view scroll-y="true" style="height: {{windowHeight}}rpx" bindscroll="scroll" bindscrolltolower="scrolltolower"><view class="film"><block wx:for="{{films}}" wx:for-index="filmIndex" wx:for-item="filmItem" wx:key="film"><view data-id="{{filmItem.id}}" class="film-item" catchtap="viewFilmDetail"><view class="film-cover"><image src="{{filmItem.images.large}}" class="film-cover-img"></image><view class="film-rating"><block wx:if="{{filmItem.rating.average == 0}}">暫無評(píng)分</block><block wx:else>{{filmItem.rating.average}}分</block></view></view><view class=