zoukankan      html  css  js  c++  java
  • Vue中如何书写js来渲染页面填充数据的部分代码

    
    
    new Vue({
    el:"#app" ,
    data:{
    user:{
    id:"",
    username:"",
    password:"",
    age:"",
    sex:"",
    },
    userList:[]
    },
    methods:{
    findAll:function () {
    //在当前方法中定义一个变量,表明是vue对象
    var _this= this;
    axios.get('/day01_eesy_vuejsdemo/user/findAll.do')
    .then(function (response) {
    // handle success
    _this.userList=response.data;
    console.log(response);
    })
    .catch(function (error) {
    // handle error
    console.log(error);
    })
    .finally(function () {
    // always executed
    });
    },
    findById:function (userid) {
    //在当前方法中定义一个变量,表明是vue对象
    var _this= this;
    axios.get('/day01_eesy_vuejsdemo/user/findById.do',{params:{id:userid}})
    .then(function (response) {
    // handle success
    _this.user=response.data;
    $("#myModal").modal("show");
    console.log(response);
    })
    .catch(function (error) {
    // handle error
    console.log(error);
    })
    .finally(function () {
    // always executed
    });
    },
    update:function (user) { //post请求
    //在当前方法中定义一个变量,表明是vue对象
    var _this= this;
    axios.post('/day01_eesy_vuejsdemo/user/updateUser.do', _this.user)
    .then(function (response) {
    _this.findAll();
    console.log(response);
    })
    .catch(function (error) {
    console.log(error);
    });
    }
    },
    created:function(){
    this.findAll();
    }
    });
     
  • 相关阅读:
    微服务-SpringCloud学习系列(二):注册中心Eureka
    Spring Security系列(一)简介
    程序人生(一)--习惯与性格
    JavaEE系列(一)--Filter技术
    JavaEE系列(一)--Servlet技术
    微服务-SpringCloud学习系列(一):认识微服务
    mongoDB安装
    php遍历目录下的文件
    mysql创建视图
    ssh 安全策略
  • 原文地址:https://www.cnblogs.com/newcityboy/p/12222730.html
Copyright © 2011-2022 走看看