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;
                    }
                }
            })
  • 相关阅读:
    校验函数
    声明
    主程序(开始检查)
    活代码LINQ——09
    活代码LINQ——08
    活代码LINQ——07
    活代码LINQ——06
    活代码LINQ——05
    活代码LINQ——04
    活代码LINQ——03
  • 原文地址:https://www.cnblogs.com/heyiping/p/11880586.html
Copyright © 2011-2022 走看看