好了这事一个非常艰巨的任务  解释以下的全部代码

<template>
<div class="hello">
<p style="color:gray">
提示:在vscode terminal中使用npm run server启动服务,否则是看不到效果的
</p>
<!-- <el-button @click="check">点击以测试接口</el-button>
<el-row>
<el-select v-model="method">
<el-option
v-for="(m, key) in methods"
:key="key"
:label="m + '(' + key + ')'"
:value="key"
></el-option>
</el-select>
</el-row>
<el-row style="width:40%;">
用户名:<el-input v-model="id"></el-input> 密码:<el-input v-model="password"></el-input> 年龄:<el-input v-model="age"></el-input> 性别:<el-input v-model="sexual"></el-input>
</el-row> -->
<h1 style="text-align:center">
用户操作表
</h1>
<pre>
{{ result }}
</pre>
<!---测试案例-->
<el-row>
<el-button @click="addUser">添加用户</el-button>
</el-row>
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="id" label="用户名" width="180"> </el-table-column>
<el-table-column prop="password" label="用户密码" width="180">
</el-table-column>
<el-table-column prop="age" label="年龄"> </el-table-column>
<el-table-column prop="sexual" label="性别">
<template slot-scope="scope">
{{ scope.row.sexual ? "女" : "男" }}
</template>
</el-table-column>
<el-table-column prop="age" label="年龄">
<template slot-scope="scope">
<el-button @click="editUser(scope.row)" type="text" size="small"
>编辑</el-button
>
<el-button @click="removeUser(scope.row)" type="text" size="small"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<el-dialog :visible.sync="showDialog">
<el-row style="width:40%;">

用户名:<el-input v-model="id" :disabled="mode == 'update'"></el-input> 密码:<el-input v-model="password"></el-input> 年龄:<el-input-number v-model="age"></el-input-number> 性别:<el-select v-model="sexual">
<el-option label="男" :value="0"></el-option>
<el-option label="女" :value="1"></el-option>
</el-select>
</el-row>
<div slot="footer">
<el-button @click="showDialog = false">取 消</el-button>
<el-button type="primary" @click="apply(mode)">{{
mode == "add" ? "创建" : "编辑"
}}</el-button>
</div>
</el-dialog>
</div>
</template>

下面是脚本了
<script>
export default {
name: "HelloWorld",
mounted() {
this.refreshTable();
},
data() {
return {
showDialog: false,
mode: "add",
tableData: [],
methods: {
save: "保存用户信息",
update: "修改用户信息",
check: "验证密码",
delete: "删除用户",
add: "添加用户",
get: "获取用户信息"
},
method: "check",
result: "",
age: "",
sexual: "",
id: "",
password: ""
};
},
methods: {
apply(mode) {
this.send(
mode,
{
id: this.id,
password: this.password,
sexual: this.sexual,
age: this.age
},
() => {
this.refreshTable();
this.showDialog = false;
}
);
},
addUser() {
this.showDialog = true;
this.mode = "add";
["id", "sexual", "age", "password"].forEach(item => {
this[item] = undefined;
});
},
editUser(source) {
this.showDialog = true;
this.mode = "update";
["id", "sexual", "age", "password"].forEach(item => {
this[item] = source[item];
});
},
removeUser(user) {
this.send("delete", user, () => {
this.refreshTable();
});
},
send(method, option, callback) {
this.result = "";
this.$axios.post("/user/" + method, option).then(res => {
let result = res.data;
if (result.status == -1) {
alert(result.msg);
return;
}
callback(result.data && JSON.parse(JSON.stringify(result.data)));
});
},
refreshTable() {
this.send("get", {}, data => {
this.tableData = data;
});
},
check() {
this.result = "";
this.$axios
.post("/user/" + this.method, {
id: this.id,
age: this.age,
password: this.password,
sexual: this.sexual
})
.then(res => {
console.log("res=>", res);
this.result = res.data;
});
}
}
};
</script>

第十三篇:axios网络通信的更多相关文章

  1. 解剖SQLSERVER 第十三篇 Integers在行压缩和页压缩里的存储格式揭秘(译)

    解剖SQLSERVER 第十三篇    Integers在行压缩和页压缩里的存储格式揭秘(译) http://improve.dk/the-anatomy-of-row-amp-page-compre ...

  2. 第十三篇 Integration Services:SSIS变量

    本篇文章是Integration Services系列的第十三篇,详细内容请参考原文. 简介在前一篇我们结合了之前所学的冒泡.日志记录.父子模式创建一个自定义的SSIS包日志记录模式.在这一篇,我们将 ...

  3. Python之路【第十三篇】:jQuery -暂无内容-待更新

    Python之路[第十三篇]:jQuery -暂无内容-待更新

  4. Python开发【第二十三篇】:持续更新中...

    Python开发[第二十三篇]:持续更新中...

  5. Python开发【第十三篇】:jQuery(二)

    http://www.bubuko.com/infodetail-1438296.html 处理完毕需要整理贴进来 Python之路[第十三篇]jQuery案例-Form表单&插件及扩展   ...

  6. Python开发【第十三篇】:jQuery--无内容点击-不进去(一)

    Python开发[第十三篇]:jQuery--无内容点击-不进去(一)

  7. 十三篇系列:king转折点,wooga瓶颈,supercell营收结构

    转自:http://gamerboom.com/archives/95125 十三篇系列:king的历史转折点,wooga的瓶颈,supercell的营收结构 第一篇 这句话In other word ...

  8. 【译】第十三篇 Integration Services:SSIS变量

    本篇文章是Integration Services系列的第十三篇,详细内容请参考原文. 简介在前一篇我们结合了之前所学的冒泡.日志记录.父子模式创建一个自定义的SSIS包日志记录模式.在这一篇,我们将 ...

  9. 跟我学SpringCloud | 第十三篇:Spring Cloud Gateway服务化和过滤器

    SpringCloud系列教程 | 第十三篇:Spring Cloud Gateway服务化和过滤器 Springboot: 2.1.6.RELEASE SpringCloud: Greenwich. ...

随机推荐

  1. 使用HBuilder X编辑器安装终端窗口插件未响应的解决方案

    一.打开HBuilder X根目录 依次找到main.js HBuilderX \ plugins \ builtincef3terminal \ script \ main.js 二.编辑main. ...

  2. SAP Web Dynpro-集成消息

    您可以使用消息管理器将消息集成到消息日志中. 您可以使用Web Dynpro代码向导打开消息管理器. 您可以从工具栏中打开Web Dynpro代码向导. 当您的ABAP工作台处于更改模式或编辑视图或控 ...

  3. Leetcode----<Re-Space LCCI>

    题解如下: /** * 动态规划解法: * dp[i] 表示 0-i的最小不能被识别的字母个数 * 求 dp[k] 如果第K个字母 不能和前面的字母[0-{k-1}]合在一起被识别 那么dp[k] = ...

  4. Windows 2008R2 IIS环境配置(靶机)

    一.Windows 2008 R2系统安装 VMware Workstation 15安装包 链接:https://pan.baidu.com/s/11sYcZTYPqIV-pyvzo7pWLQ 提取 ...

  5. 解决nginx反向代理Mixed Content和Blockable问题

    nginx配置https反向代理,按F12发现js等文件出现Mixed Content,Optionally-blockable 和 Blockable HTTPS 网页中加载的 HTTP 资源被称之 ...

  6. zabbix监控钉钉报警

    1. bash脚本 #!/bin/bash to=$1 subject=$2 text=$3 #此处的 xxxxx 就是刚刚复制存留的 api 接口地址. curl -i -X POST \ 'htt ...

  7. zabbix监控mysql主从同步

    获取主从复制sql线程和I/O线程状态是否为yes #!/bin/bash HOSTNAME="数据库IP" PORT="端口" USERNAME=" ...

  8. fiddle如何使用代理

    前言 Fiddle作为抓包工具深受程序员的喜爱,可能在代理方面有些会感觉到迷惑的,可以通过本文的学习来掌握一些基本的知识. Fiddle介绍 Fiddler是位于客户端和服务器端的HTTP代理,也是目 ...

  9. .NET ORM框架HiSql实战-第一章-集成HiSql

    一.引言 做.Net这么多年,出现了很多很多ORM框架,比如Dapper,Sqlsugar,Freesql等等.在之前的项目中,用到的ORM框架也大多数是这几个老牌的框架. 不过最近园子关于.NET ...

  10. NC13822 Keep In Line

    NC13822 Keep In Line 题目 题目描述 又到饭点了,SK同学靠着惯性走到了食堂,但长长的队伍顿时让他失去了食欲.突然,他注意到某个窗口前的队伍里明显存在插队的现象,于是他默默记录下了 ...