移動(dòng)頁面示例項(xiàng)目:vue-mobile-demo

今天把這兩天做的Demo上傳到github上,生成了一個(gè)示例項(xiàng)目:vue-mobile-demo,希望能夠?qū)π率钟兴鶐椭?/p>

下面就簡(jiǎn)單介紹一下這個(gè)項(xiàng)目的內(nèi)容

基本情況

該項(xiàng)目基于vant-demo項(xiàng)目,增加了許多實(shí)用功能,涉及到了vue+vant+axios+mockjs等,是新手開發(fā)的良好起點(diǎn)。包括了首頁/申請(qǐng)/查詢/設(shè)置四個(gè)頁面,由底部導(dǎo)航欄進(jìn)行切換。

底部導(dǎo)航欄

其中申請(qǐng)頁面又包括了四個(gè)階段,由一個(gè)主控頁面加四個(gè)組件構(gòu)成

進(jìn)度展示

功能特點(diǎn)

單頁面組件的設(shè)計(jì)(Foot.vue,存放中components目錄下)

<template>
  <div class="footer">
    <van-tabbar v-model="active">
      <van-tabbar-item icon="home-o" to="home">首頁</van-tabbar-item>
      <van-tabbar-item icon="friends-o" to="info" dot>申請(qǐng)</van-tabbar-item>
      <van-tabbar-item icon="search" to="search">查詢</van-tabbar-item>
      <van-tabbar-item icon="setting-o" to="user" info="5">設(shè)置</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import { Tabbar, TabbarItem } from 'vant';
export default {
    name: 'apo-foot',
    components: {
        [Tabbar.name]: Tabbar,
        [TabbarItem.name]: TabbarItem
    },
    data () {
      return {
        active: 0
      }
    }
}
</script>

進(jìn)度流程組件

<template>
    <div class="info">
        <div class="fixed">
        <van-steps :active="active">
            <van-step>填寫信息</van-step>
            <van-step>智能匹配</van-step>
            <van-step>產(chǎn)品申請(qǐng)</van-step>
            <van-step>反饋結(jié)果</van-step>
        </van-steps>
    </div>
    <div class="step-mask"></div>
    <div :is="currentView"></div>   
    <div class="van-hairline--top"></div>
    <van-row>
        <van-col offset="6" span="12">
            <van-button 
                type="primary" 
                size="large" 
                :text="buttonTip"
                @click="nextStep"
            ></van-button>
        </van-col>
    </van-row>
    </div>
</template>

列表組件

<template>
  <div class="products">
    <van-radio-group v-model="radio">
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="沒有更多了"
      @load="onLoad">
      <van-radio 
        v-for="item in list"
        :key="item.id"
        :name="item.id" >
          <apo-cell
            :newsData="item"
            :key="item.id" />
      </van-radio>
    </van-list>
    </van-radio-group>
  </div>
</template>

Mock請(qǐng)求

const Mock = require('mockjs');
const Random = Mock.Random;

const produceNewsData = function() {
    let articles = [];
    for (let i = 0; i < 10; i++) {
        let newArticleObject = {
            id: i,
            title: Random.csentence(5, 30),
            thumbnail_pic_s: Random.dataImage('300x250', 'mock picture'),
            author_name: Random.cname(),
            date: Random.date() + ' ' + Random.time()
        }
        articles.push(newArticleObject)
    }
 
    return {
        articles: articles
    }
}
 
Mock.mock('/news/index', 'post', produceNewsData);

Axios請(qǐng)求

import axios from 'axios'
import vue from 'vue'
 
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
 
axios.interceptors.request.use(function(config) {
    return config;
  }, function(error) {
    return Promise.reject(error);
  })

axios.interceptors.response.use(function(response) {
  return response;
}, function(error) {
  return Promise.reject(error);
})
 
export function fetch(url, params) {
  return new Promise((resolve, reject) => {
    axios.post(url, params)
      .then(response => {
        resolve(response.data);
      })
      .catch((error) => {
        reject(error);
      })
  })
}
 
export default {
  getNews(url, params) {
    return fetch(url, params);
  }
}

跨域請(qǐng)求代理

devServer: {
   open: process.platform === 'darwin',
   host: '0.0.0.0',
   port: 8080,
   https: false,
   hotOnly: false,
   proxy: 'proxy_url'
}

更多內(nèi)容請(qǐng)參考github項(xiàng)目:https://github.com/SagittariusZhu/vue-mobile-demo

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 基于Vue的一些資料 內(nèi)容 UI組件 開發(fā)框架 實(shí)用庫 服務(wù)端 輔助工具 應(yīng)用實(shí)例 Demo示例 element★...
    嘗了又嘗閱讀 1,287評(píng)論 0 1
  • UI組件 element- 餓了么出品的Vue2的web UI工具套件 Vux- 基于Vue和WeUI的組件庫 m...
    柴東啊閱讀 15,963評(píng)論 2 140
  • UI組件 element- 餓了么出品的Vue2的web UI工具套件 Vux- 基于Vue和WeUI的組件庫 m...
    小姜先森o0O閱讀 10,130評(píng)論 0 72
  • 2019年2月24日 有霧 昨天晚飯后,我到蛋糕房買面包,女兒挑了一塊兒一人份的藍(lán)莓蛋糕,平常她都是在蛋糕房吃了回...
    艾熙子閱讀 474評(píng)論 2 6
  • 什么是最重要的事?不同的人會(huì)有不同的答案,我常常想我生命中什么樣的事是最重要的。陪伴家人,奮斗一生,這在我眼里都非...
    晨希yang閱讀 225評(píng)論 0 1

友情鏈接更多精彩內(nèi)容