因爲咱們沒有設計的支持,因此爲了學習這個小程序的製做,咱們暫且模擬一個成熟的小程序來幫助你們快速的熟悉小程序的製做。個人教程可能寫的不是很好,但願你結合我給的demo可以更快的學會小程序,小程序地址,點擊這裏javascript
{ "pages":[ "pages/index/index" "pages/logs/logs" ] }
{ "window":{ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black", "navigationBarTitleText": "仿製京東", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light" } }
"tabBar": { "color": "#ccc", "selectedColor":"#0f0", "backgroundColor":"#567567", "borderStyle":"white", "position":"bottom", "list": [{ "pagePath": "pages/index/index", "iconPath":"img/icon_API.png", "selectedIconPath":"img/icon_API_HL.png", "text": "搜索商品" }, { "pagePath": "pages/logs/logs", "iconPath":"img/wechat.png", "selectedIconPath":"img/wechatHL.png", "text": "個人訂單" }] }
<view class="section"> <view class="section-title" hover-class="section-hover">flex-direction: row</view> <view class="flex-wrp" style="flex-direction:row;"> <view class="flex-item bc-green">1</view> <view class="flex-item bc-red">2</view> <view class="flex-item bc-blue">3</view> </view> </view>
<!-- 樣式應該寫到css文件中 --> <image style="width: 200px; height: 200px; background-color: #eeeeee;" mode="{{item.mode}}" src="圖片相對路徑"></image>
每一個js文件中都有一個Page實例,引入外部的js文件的時候用require引用一個相對路徑,獲取app.js中的app對象使用var app = getApp();css
Page({ data: { logs: [], userInfo:{}, orderData:orderData, dialogFlag:false }, directHandle:function(event){ console.log(event) if(event.target.id === '3'){ this.setData({ dialogFlag:true }) } }, dialogCancel:function(){ this.setData({ dialogFlag:false }) }, showDialog:function(){}, onLoad: function () { wx.setNavigationBarTitle({ title: '個人訂單' }) //調用全局的方法獲取用戶信息 var that = this; app.getUserInfo(function(userInfo){ //更新數據 that.setData({ userInfo:userInfo }) }) console.log(this.data.userInfo) } })
<view> {{ message }} </view> Page({ data: { message: 'Hello MINA!' } })
若是要生成多個列表的時候,須要在data中定義一個數據數組,而後在你須要重複的標籤上添加一個wx:for的屬性,屬性值爲用花括號包起來的數據數組,每一項就是item,下標是index
```
[
{
orderIconUrl:'../../img/pause.png',
navUrl:'/pages/myOrder/myOrder',
name:'所有訂單'
},
{
orderIconUrl:'../../img/play.png',
navUrl:'/pages/myOrder/myOrder',
name:'代付款'
},
{
orderIconUrl:'../../img/plus.png',
navUrl:'/pages/myOrder/myOrder',
name:'代收款'
},
{
orderIconUrl:'../../img/record.png',
navUrl:'/pages/selfInfo/selfInfo',
name:'售後訂單'
},
]html
<navigator wx:for="{{orderData}}" wx:key="navUrl" url="{{item.navUrl}}" id="{{index}}" bindtap="directHandle" open-type="navigate"> <image class="icon" src="{{item.orderIconUrl}}"></image> <text>{{item.name}}</text> <image class="right" src="../../img/arrowright.png"></image> </navigator>
```java
進行跳轉的時候若是使用的navigate標籤進行的跳轉,地址後面加的參數會在目標頁面的onLoad函數的參數獲取到,若是是使用wx:navigate等方法進行跳轉的話,路徑後面的參數會在success函數的參數中獲取到git