Asp.net+Vue2構(gòu)建簡單記賬WebApp之五(vue.js構(gòu)建記賬頁面)

Asp.net+Vue2構(gòu)建簡單記賬WebApp之一(設(shè)計(jì))
Asp.net+Vue2構(gòu)建簡單記賬WebApp之二(使用ABP迅速搭建.Net后臺)
Asp.net+Vue2構(gòu)建簡單記賬WebApp之三(使用Vue-cli構(gòu)建vue.js應(yīng)用)
Asp.net+Vue2構(gòu)建簡單記賬WebApp之四(vue.js構(gòu)建記賬主頁面)
Asp.net+Vue2構(gòu)建簡單記賬WebApp之五(vue.js構(gòu)建記賬頁面)
Asp.net+Vue2構(gòu)建簡單記賬WebApp之六(vue.js構(gòu)建記賬統(tǒng)計(jì)頁面)
源碼下載

一、編輯記賬頁面hello.vue

<template>
  <div>
    <div id="TopTitle">
      <mt-header v-bind:title="msg">
      </mt-header>
      <mt-field label="¥" placeholder="在此輸入記賬金額" type="number" v-model="money"></mt-field>
    </div>
    <div id="BillTypes" >
      <div v-for="item in billType" :key="item.id" class="item" v-on:click="Add(item.id)">
        <div class="item_img">
          <i class="fa fa-3x" v-bind:class="item.fontStyle"></i>
        </div>
        <span>{{item.name}}</span>
      </div>

      <div style="clear: both"></div>

    </div>
  </div>
</template>

<script>
  import { Toast } from 'mint-ui'; // 引入mint-ui彈窗,對于js要調(diào)用的還需要這樣引用一下。不知道為什么
  export default {
    name: 'hello',
    data() {
      return {
        msg: '理財(cái)從記賬開始',
        billType: [], // 賬單數(shù)據(jù)
        money: '',   // 記賬的金額
      }
    },
    created() {
      this.$http.get('/bill/GetBillType').then(response => {
        this.billType = response.body.result.data;
      }, response => {
        Toast("獲取數(shù)據(jù)出錯(cuò)")
      });
    },
    methods: {
      Add(m) {
        if (this.money == '') {
          Toast('請先輸入記賬金額,再選擇資金去向');
          return;
        }
        ;
        this.$http.post('/bill/AddBills', {
          Money: this.money,
          BillTypeId: m,
        }).then(r => {
          if (r.body.result.result) {
            Toast({
              message: '記賬成功',
              iconClass: 'icon icon-success'
            });
            this.money = '';
          } else {
            Toast(r.body.result.data);
          }
        }, r => {
          Toast("數(shù)據(jù)傳輸失敗");
        })


      },
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  #TopTitle{
    position: fixed;
    top: 0;
    width: 100%;
    background-color: #eee;
    z-index: 1;
  }
  #TopTitle div *{
    border-style: none;
  }
  #BillTypes{
    margin-top: 88px;
    position: relative;
    height: auto;
    background-color: #eee;
  }
  #BillTypes .item{
    height: 100px;
    padding: 11px 15px;
    vertical-align: top;
    border-right: 1px solid #fff;
    border-bottom: 1px solid #fff;
    position: relative;
    float: left;
    width: 33.33333%;
    box-sizing: border-box;
  }
  #BillTypes .item .item_img{
    clear: both;
    padding-bottom: 8px;
  }
</style>

二、發(fā)布查看效果

因?yàn)橛玫搅撕笈_數(shù)據(jù),所以要在asp.net端配合后臺才能查看效果。
我調(diào)試時(shí),直接在本地部署了一個(gè)網(wǎng)站,網(wǎng)站地址指向的就是項(xiàng)目的web文件夾。然后瀏覽器輸入地址即可。為了方便,我將asp.net中homeControler進(jìn)行了修改。

using System.Web.Mvc;
using Abp.Web.Mvc.Authorization;

namespace MyBill.Web.Controllers
{
   // [AbpMvcAuthorize]
    public class HomeController : MyBillControllerBase
    {
        public ActionResult Index()
        {
            Response.Redirect("/mybill/dist/index.html");
            return View();
        }
    }
}
這里寫圖片描述

三、總結(jié)

1、使用vue-resource 來獲取/傳輸數(shù)據(jù),更多方法參看官網(wǎng)
2、created() 不同vue2中新添的內(nèi)容實(shí)現(xiàn)構(gòu)建完成執(zhí)行。更多參看下圖。

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

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

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