10步完成Abp(.net core)+Vue的Demo?

來源:互聯網
上載者:User

標籤:layout   bind   scripts   smis   mis   net   static   技術分享   title   

1.去abp官網產生項目,選擇.net core1.x版本 

2.Nuget還原包,需裝dotnet core1.1等。

3.新增一個entity,並加入到上下文中

 

4.然後cmd命令列工具切換到專案檔AbpCore.EntityFramewor目錄下,輸入命令dotnet ef migration add "initdata" 命令,接著輸入dotnet ef database update,執行完成組建資料庫.

 

6.添加剛才添加的entity對應的service層,就是簡單的增改查,這裡不再詳細描述(會動態產生api)

 

7.建立控制器,view等頁面,引入vuejs檔案

 

 8.根據動態產生的api完成資料的擷取,以及添加,修改

 js檔案

        var _dailyMoneyService = abp.services.app.dailyMoney;        var app = new Vue({            el: "#moneyApp",            data: {                moneyModel: {                    id:null,                    date:"",                    moeny: 0,                    desc:""                },                moneyList: []            },            methods: {                getMoneyList:function() {                    var _this = this;                    _dailyMoneyService.getDailyMoneyList().done(function(result) {                        _this.moneyList = result;                    });                },                saveMoney: function () {                    var _this = this;                    _dailyMoneyService.createOrUpdateMoney(_this.moneyModel).done(function () {                        location.reload();                    });                },                editMoney: function (id) {                    var _this = this;                    abp.ui.setBusy();                    _dailyMoneyService.getMoneyForEdit(id).done(function (result) {                        _this.moneyModel = result;                    }).always(function () {                        abp.ui.clearBusy();                    });                    $(‘#MoneyModal‘).modal();                }            }        });    app.getMoneyList();

 view

@*    For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860*@@{    Layout = "~/Views/Shared/_VLayout.cshtml";}@section scripts{    <script src="~/view-resources/Views/Money/Index.js" asp-append-version="true"></script>}<div id="moneyApp">    <div class="row">        <div class="col-md-12">            <button data-toggle="modal" data-target="#MoneyModal" class="btn btn-primary pull-right"><i class="fa fa-plus"></i>添加消費記錄</button>        </div>    </div>    <div class="row">        <table class="table">            <thead>                <tr>                    <th>編號</th>                    <th>日期</th>                    <th>金額</th>                    <th>描述</th>                </tr>            </thead>            <tbody>                <tr v-for="moeny in moneyList">                    <td><a href="javascript:void(0)" v-on:click="editMoney(moeny.id)">{{moeny.id}}</a></td>                    <td>{{moeny.date}}</td>                    <td>{{moeny.moeny}}</td>                    <td>{{moeny.desc}}</td>                </tr>            </tbody>        </table>    </div>    <div class="modal fade" id="MoneyModal" tabindex="-1" role="dialog" data-backdrop="static">        <div class="modal-dialog" role="document">            <div class="modal-content">                <form name="moneyForm" role="form" novalidate class="form-validation">                    <div class="modal-header">                        <h4 class="modal-title">                            <span v-if="moneyModel.id">編輯消費記錄</span>                            <span v-if="!moneyModel.id">添加消費記錄</span>                        </h4>                    </div>                    <div class="modal-body">                        <input type="hidden" v-model="moneyModel.id"/>                        <div class="form-group">                            <label>日期</label>                            <input class="form-control" type="text" v-model="moneyModel.date" required>                        </div>                        <div class="form-group">                            <label>金額</label>                            <input class="form-control" type="text" v-model="moneyModel.moeny" required>                        </div>                        <div class="form-group">                            <label>描述</label>                            <input class="form-control" type="text" v-model="moneyModel.desc" required>                        </div>                    </div>                    <div class="modal-footer">                        <button type="button" class="btn btn-default" data-dismiss="modal">@L("Cancel")</button>                        <button type="button" class="btn btn-primary blue" v-on:click="saveMoney" ><i class="fa fa-save"></i> <span>@L("Save")</span></button>                    </div>                </form>            </div>        </div>    </div></div>

 

 9.效果示範

 

 

 10.疑問,不知道這樣使用vue是否符合規範,我感覺有點問題,請各位賜教。

10步完成Abp(.net core)+Vue的Demo?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.