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 @ 2022-05-01 21:50  超级氯化钾  阅读(83)  评论(0)    收藏  举报