第一步 項目配置一、編寫app.json對整個項目的公共配置1、pages:配置頁面路徑(必須),列出所有的頁面的路徑,所有存在的頁面都需要在此寫出,否則在頁面跳轉(zhuǎn)的時候會報出找不 ...
對整個項目的公共配置
1、pages:配置頁面路徑(必須),列出所有的頁面的路徑,所有存在的頁面都需要在此寫出,否則在頁面跳轉(zhuǎn)的時候會報出找不到頁面的錯誤
2、window:窗口配置,配置導航及窗口的背景色和文字顏色,還有導航文字和是否允許窗口進行下拉刷新
3、tabBar:tab欄配置,配置tab欄背景色及出現(xiàn)位置,上邊框的顏色(目前只支持黑或白),文字顏色及文字選中顏色,最核心的配置是list即tab欄的列表,官方規(guī)定最少2個,最多5個,每個列表項目可配置頁面路徑、文字、圖標及選中時圖標的地址
4、network:網(wǎng)絡配置,配置網(wǎng)絡請求、上傳下載文件、socket連接的超時時間
5、debug:調(diào)試模式,建議開發(fā)時開啟(true),可以看到頁面注冊、頁面跳轉(zhuǎn)及數(shù)據(jù)初始化的信息,另外報錯的錯誤信息也會比較詳細
{"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}}">暫無評分</block><block wx:else>{{filmItem.rating.average}}分</block></view></view><view class=