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

<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. 24.Haproxy搭建Web群集

    Haproxy搭建Web群集 目录 Haproxy搭建Web群集 Haproxy简介 常见的Web集群调度器 软件类 硬件类 Haproxy应用分析 HAProxy的主要特性 HAProxy常见的8种 ...

  2. 全新升级的AOP框架Dora.Interception[3]: 基于特性标注的拦截器注册方式

    在Dora.Interception(github地址,觉得不错不妨给一颗星)中按照约定方式定义的拦截器可以采用多种方式注册到目标方法上.本篇文章介绍最常用的基于"特性标注"的拦截 ...

  3. 关于kali安装输入法

    之前老是被kali大小写输入恶心坏了,正好看到一篇文章写kali安装搜狗输入法的,虽然不需要输入中文,但是英文输入就很方便了. 一.切换root用户登录 1.sodu su切换为root权限 2.pa ...

  4. 华为AppLinking中统一链接的创建和使用

    ​ 运营的同学近期在准备海外做一波线下投放,涉及到海外的Google Play,iOS设备的App Store,以及华为渠道的AppGallery. 其中运营希望我们能够将三个平台的下载整合到一个链接 ...

  5. SAP Grid control( ALV Grid 列表 自定义 按钮)

    ALV 列表和按钮 效果 源代码 PROGRAM bcalvc_tb_menu_with_def_but. *&&&&&&&&& ...

  6. 监控pos收银机

    1.打开pos收银机snmp功能 控制面板-->程序和功能-->启用或关闭windows功能→简单网络管理协议(SNMP) 2.配置snmp服务 控制面板-->管理工具-->服 ...

  7. Go flag 详解,实现二级子命令

    前言 日常开发使用到的命令行工具大都支持如下特性: 文档自动生成(如 -h --help) 多级子命令(如 docker exec -it) 支持参数(如 ls -color=auto) 长短选项(如 ...

  8. ajax02_封装自己的jQuery库和ajax请求

    封装自己的ajax类库 首先封装自己的 jQuery库 启发:css的元素选择器思想 简单的代码实现 function jQuery(selector){ if(typeof selector == ...

  9. linux 编译式安装apache

    apache的安装需要两个组件,APR对于Tomcat最大的作用就是socket调度 组件下载解压完成 ,讲两个组件解压包移动到apache的类库文件夹内 注:如果系统自带了apr和apr-util可 ...

  10. mysql 经典案例

    MySQL多表联合查询是MySQL数据库的一种查询方式,下面就为您介绍MySQL多表联合查询的语法,供您参考学习之用. MySQL多表联合查询语法: SELECT * FROM 插入表 LEFT JO ...