vue推荐ajax语法axios插件
[http://www.axios-js.com/docs/](http://www.axios-js.com/docs/)
```
npm install axios
```
```
created () {
this.token = this.$route.query.token
// console.log(this.token)// 输出路径传值
if (this.token) {
this.tokenlogin()
} else { console.log('需要输入登录跳转跳转') }
},
methods: {
// tokenlogin登录验证
tokenlogin: function () {
const axios = require('axios')
axios.get('login/tokenlogin?token=' + this.token).then(res => {
if (res.data.code !== 1) return this.$message.error(res.data.msg)
this.$message.success(res.data.msg)
console.log(res.data.token)
window.sessionStorage.setItem('token', res.data.token)
this.$router.push('/Home')
})
},
// 登录验证
login () {
console.log(this.loginForm)
// console.log(this.loginForm.password)
this.$refs.loginFormRef.validate(async valid => {
console.log(valid)
if (!valid) return
const { data: res } = await this.$http.post('login/login', this.loginForm)
if (res.code !== 1) return this.$message.error(res.msg)
this.$message.success(res.msg)
console.log(res)
window.sessionStorage.setItem('token', res.token)
this.$router.push('/Home')
// console.log(window.sessionStorage.getItem('token'))
})
}
}
```
不推荐语法
```
// POST请求
// this.$http({
// type: 'POST',
// url: 'http://json.ui-china.cn/dadian/login/login',
// method: '',
// // 请求体重发送的数据
// data: {
// password: this.loginForm.password,
// username: this.loginForm.username
// }
// // 设置请求头
// // headers: {
// // 'Content-Type': '123-123'
// // }
// }).then(function (deta) {
// // 请求成功回调
// console.log(deta)
// // 请求成功回调
// }, function () {
// // 请求失败回调
// })
// $.ajax({
// type: 'post',
// url: 'http://json.ui-china.cn/dadian/login/login',
// data: this.loginForm,
// async: false,
// dataType: 'json',
// headers: {
// 'Content-Type': '123-123'
// },
// success: function (res) {
// console.log(res)
// if (res.code !== 1) {
// console.log(0)
// }
// console.log(1)
// }
// })
```
- HTML
- 讯飞插件
- Python
- 王者荣耀
- demo_cg.py
- demo_cg_TT.py
- img.py
- MySQL
- 清空表数据
- ID自增长重置
- 用户密码及权限操作
- 外键在数据库中的作用
- MySQL增删改查语句
- DDL-数据库操作
- DDL-表操作-查询
- DDL-表操作-创建
- DDL-表操作-数据类型
- DDL-表操作-修改
- DDL-表操作-删除
- DML-语句
- DML-添加数据
- DML-修改数据
- DML-删除数据
- DQL-语法
- DQL-基本查询
- DQL-条件查询
- DQL-聚合函数
- DQL-分组查询
- DQL-排序查询
- DQL-分页查询
- DCL-介绍
- DCL-管理用户
- DCL-权限控制
- 函数
- JS
- ajax
- ajax get请求
- ajax post提交
- ajax 同时上传文本和文件到数据库(inpt text和input file)
- 路径传值+接收解析
- js 本地sessionStorage
- js Excel导出.xls
- 二维码生成插件
- VUE-CLI4
- 安装手脚架及插件
- ECharts-数据可视化
- element-ui-时间戳
- qrcode二维码生成插件
- vuedraggable-拖拽组件
- vue-drag-resize-自由拖拽、缩放组件
- gitee配置
- src
- plugins
- element.js
- echartsMixin.js
- views
- login
- login.vue
- btn.vue
- home
- home.vue
- Welcome.vue
- user
- users.vue
- router
- main.js
- App.vue
- 引入语法
- 获取路径传值
- ajax请求
- token语法
- NPM更换镜像方案
- PHP
- PHP 微信网页登录
- PHP 判断函数
- PHP 获取微信公众号openid
- PHP 实现发送模板消息(微信公众号版)
- PHP 阳历阴历转换计算生肖闰年
- PHP 接口数组形式
- PHP 同文件夹下顺序命名
- PHP 输出文件
- PHP E-mail发送
- PHP cURL资源
- PHP 远程访问控制服务器
- PHP 8.0 开启mysqli扩展
- PHP 使用 OSS 批量上传图片
- PHP md5 加密与解密
- ThinkPHP
- PT6
- TP6安装多应用
- TP5
- view渲染模板常见语法
- Visual Studio Code
- 介绍
- 插件-eslint
- vs code插件
- VSCode添加自定义模板
- SFTP
- md格式的文档
- mermaid
- frp内网穿透
- 自定义端口
- ui-china.cn
- 常用软件
- 框架
- 服务器
- 微信小程序
- 云函数 Email
- 参数传递
- 其他
- VMware虚拟机centos7设置静态ip 连接外网