首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Asp.net+Vue2构建简单记账WebApp之五(vue.js构建记账页面)

Asp.net+Vue2构建简单记账WebApp之五(vue.js构建记账页面)

作者头像
易兒善
发布2018-08-21 15:20:14
6400
发布2018-08-21 15:20:14
举报
文章被收录于专栏:挖坑填坑挖坑填坑

一、编辑记账页面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要调用的还需要这样引用一下。不知道为什么
  export default {
    name: 'hello',
    data() {
      return {
        msg: '理财从记账开始',
        billType: [], // 账单数据
        money: '',   // 记账的金额
      }
    },
    created() {
      this.$http.get('/bill/GetBillType').then(response => {
        this.billType = response.body.result.data;
      }, response => {
        Toast("获取数据出错")
      });
    },
    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("数据传输失败");
        })


      },
    }
  }
</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>

二、发布查看效果

因为用到了后台数据,所以要在asp.net端配合后台才能查看效果。 我调试时,直接在本地部署了一个网站,网站地址指向的就是项目的web文件夹。然后浏览器输入地址即可。为了方便,我将asp.net中homeControler进行了修改。

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();
        }
    }
}

这里写图片描述

三、总结

1、使用vue-resource 来获取/传输数据,更多方法参看官网 2、created() 不同vue2中新添的内容实现构建完成执行。更多参看下图。

这里写图片描述

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.09.16 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、编辑记账页面hello.vue
  • 二、发布查看效果
  • 三、总结
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档