• 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();
    }
    });
     
  • 相关阅读:
    Linux查看进程是否存在及启动或重启
    Leetcode 31.下一个排列 tag数组
    Leetccode 27.移除元素 tag数组
    Leetcode 24:两两交换链表中的节点
    当代90后的焦虑
    典型java面试题
    TD编译环境变量说明
    ubuntu20.04安装TD工具后编译错误
    ssh免密登录在Linux服务器之间的设置
    ubuntu20.04导航栏放到底部
  • 原文地址:https://www.cnblogs.com/newcityboy/p/12222730.html
Copyright © 2020-2023  润新知