vue03-axios-cookies

安装

cnpm install axios@0.27.2 -s
在main.js配置

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import axios from 'axios'


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})


//axios支持promise,返回一个promise,调用内部的resolve
axios({
  url: 'http://123.207.32.32:8000/home/multidata',
	method: 'get' //默认是get方式
}).then(res=>{
  console.log(res)
})

cookies

cnpm install vue-cookies@1.8.1 -S



import VueCookies from 'vue-cookies';
Vue.use(VueCookies)



 this.$cookies.set('token',token,{expires: "30D"});
 this.$cookies.get('super');
posted @   超级氯化钾  阅读(67)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示