Vue引入Axios

news/2024/7/24 11:40:08 标签: javascript, 开发语言, ecmascript

1.命令安装axios和vue-axios

npm install axios --save
npm install vue-axios --save

2.package.json查看版本

3.在main.js中引用

import axios from 'axios';
import VueAxios from 'vue-axios';
Vue.use(VueAxios,axios)

4.如何使用

(初始化方法)

将下列代码放在Home.vue中:

export default {

  name: 'HomeView',

下边即可

methods:{
    getList(){
      this.axios.get('http://localhost:3312/user/getList',{
        params:{
          page:this.query.page,
          size:this.query.size,
          name:this.query.name,
          phone:this.query.phone,
          city:this.query.city
        }
      }).then((resp)=>{
        console.log(resp);
        this.tableDate =resp.data,content.list;
        this.total=resp.data.content.total;
      })
    },
  }

 


http://www.niftyadmin.cn/n/5364001.html

相关文章

网络工程师必知的网络传输介质

晚上好,我的网工朋友。 高度互联的时代下,不管是日常的互联网浏览,还是全球范围内的数据传输,都离不开一个关键的组成部分:网络传输介质。 简而言之,就是在网络中传递信息的载体。 从光纤到无线电波&…

ElementUI Form:Form表单

ElementUI安装与使用指南 Form表单 点击下载learnelementuispringboot项目源码 效果图 el-form.vue&#xff08;Form表单&#xff09;页面效果图 项目里 el-form.vue代码 <script> export default {name: el_form,data() {var checkAge (rule, value, callback…

更新npm镜像源:淘宝镜像已过期,及时切换!

你好&#xff0c;我是小白Coding日志&#xff0c;一个热爱技术的程序员。在这里&#xff0c;我分享自己在编程和技术世界中的学习心得和体会。希望我的文章能够给你带来一些灵感和帮助。欢迎来到我的博客&#xff0c;一起在技术的世界里探索前行吧&#xff01; 前言 就在昨天…

Socks5代理IP在网络爬虫领域的实战运用

Socks5代理IP在跨境电商与网络爬虫领域的实战运用是多方面的&#xff0c;主要体现在以下几个关键方面&#xff1a; 1. 网络爬虫高效抓取数据&#xff1a; - 绕过限制&#xff1a;跨境电商平台和网站通常会设置访问频率限制或地域限制来保护服务器和防止数据滥用。通过使用Socks…

同济大学|高等数学|第八版|习题1-2

同济大学&#xff5c;高等数学&#xff5c;第八版&#xff5c;习题1-2&#xff5c;2.1 同济大学&#xff5c;高等数学&#xff5c;第八版&#xff5c;习题1-2&#xff5c;2.2 同济大学&#xff5c;高等数学&#xff5c;第八版&#xff5c;习题1-2&#xff5c;2.3 同济大学&…

JAVA 栈的实现

洗盘子 时间限制&#xff1a;1.000S 空间限制&#xff1a;128MB 题目描述 在餐厅里&#xff0c;洗盘子的工作需要使用到栈这种数据结构。 假设你手里有一个盘子堆放区。现在需要模拟洗盘子的过程&#xff0c;每个盘子都有一个编号。 盘子堆放区操作说明&#xff1a; 1…

vue3上传文件到服务器

第一种方式 <el-dialog v-model"dialogFile" title"导入服务商清单" width"40%" :close-on-click-modal"false"><el-form><el-form-item><el-upload style"width: 100%" drag multiple class"up…

LF will be replaced by CRLF the next time Git touches it

参考这篇文章git提示“warning: LF will be replaced by CRLF”的解决办法-CSDN博客