zoukankan      html  css  js  c++  java
  • Vue.js的基础学习

    Vue.js的基础网上很多,这里不记录

    开始正式页面的开发

    1.页面加载时请求数据

    methods: {
                    post() {
                        //发送post请求
                        this.$http.post('../../ashx/UploadReceipt.ashx', { "Type": "GetMyConsumptionScore", "MemberID": MemberID }, { emulateJSON: true }).then(function (res) {
                            var data = res.data;
                            this.receiptdata = data;
                        }, function () {
                            console.log('请求失败');
                        })
                    }
                }

    然后想要在页面加载时调用此方法还需要在mounted中调用

    mounted: function () {
    this.post();
    },

    js完整代码

    new Vue({
                el: '.common-box',
                data: {
                    title: "标题",
                    receiptdata: null,
                },
                mounted: function () {
                    this.post();
                },
                methods: {
                    post() {
                        //发送get请求
                        this.$http.post('../../ashx/UploadReceipt.ashx', { "Type": "GetMyConsumptionScore", "MemberID": MemberID }, { emulateJSON: true }).then(function (res) {
                            var data = res.data;
                            this.receiptdata = data;
                        }, function () {
                            console.log('请求失败');
                        })
                    },
                    //返回事件
                    Backclick() {
                        window.location.href = "../../my.html";
                    },
                    //列表点击事件
                    Listclick(ID) {
                        //debugger;
                    }
                }
            })
  • 相关阅读:
    APIO dispatching
    奶牛抗议
    擦弹
    逃跑
    [Hnoi2016]网络
    [Ahoi2005]LANE 航线规划
    素数密度_NOI导刊2011提高(04)
    P2939 [USACO09FEB]改造路Revamping Trails(分层图最短路)
    洛谷P3396 哈希冲突(分块)
    洛谷P4332 [SHOI2014]三叉神经树(LCT)
  • 原文地址:https://www.cnblogs.com/heyiping/p/11880586.html
Copyright © 2011-2022 走看看