当前位置: 首页 > news >正文

免费做网站怎么盈利百度快速收录账号购买

免费做网站怎么盈利,百度快速收录账号购买,校园网站建设说明书,设计师网站pin安装如下 npm install axios 第一步:创建config配置文件,用于存放请求后端的ip地址,用于后期打包后便于修改ip地址。 注:typescript要求参数要有类型。(ES6 定义对象 属性 类型 修改的是属性的值) inte…
安装如下
npm install axios

第一步:创建config配置文件,用于存放请求后端的ip地址,用于后期打包后便于修改ip地址。

注:typescript要求参数要有类型。(ES6 定义对象 属性 类型 修改的是属性的值)

interface Config {getCookieExpires(): number;getBaseIP(): string;getBaseUrl(): string;getSQLServerBaseUrl(): string;
}const config: Config = {getCookieExpires() {return 5;},getBaseIP() {const developmentIP = "";return developmentIP;},getBaseUrl() {const developmentUrl = `http://${this.getBaseIP()}:8580/edu_examandmanage_back`;return developmentUrl;},getSQLServerBaseUrl() {const developmentSQLServerUrl = `http://${this.getBaseIP()}:9191/edu_examandmanage_back`;return developmentSQLServerUrl;},
};export default config;


 

第二步:封装axios于http文件中

注:{ type AxiosInstance, type AxiosResponse }要用type

import axios, { type AxiosInstance, type AxiosResponse } from "axios"
import config from '@/config';const http:AxiosInstance = axios.create({baseURL: config.getBaseUrl(),timeout: 30000, // 请求超时时间headers: {'Content-Type': 'application/json'}
});// 请求拦截器
http.interceptors.request.use((config) => {const token = sessionStorage.getItem('token');if (token) {config.headers.Authorization = `Bearer ${token}`;}return config;},(error) => Promise.reject(error)
);// 响应拦截器
http.interceptors.response.use((response) => response,(error) => {if (error.response?.status === 403) {// 处理权限错误}return Promise.reject(error);}
);export default http;

第三步:调用http实现get、post、delete、put方法

// 公共请求
import http from 'src/lib/http'export const ProcessApi = {// 根据ID获取仪器进度GetInstrumentProgressById(id:number) {return http.get(`/api/progress/getInstrumentProgressById?id=${id}`);},// 根据UserName获取仪器进度getInstrumentProgressByUserNumber(user_number:number) {return http.get(`/api/progress/getInstrumentProgressByUserNumber?user_number=${user_number}`);},
};

第四步:引入在单页面使用(根据组件化开发模式不需要全局注册,只需要在需要的地方引用就可以了)

以下为vue2+JavaScript版本

config.js

//全局配置信息
const config =  {//token在Cookie中存储的天数,默认7天getCookieExpires(){return 5;},getBaseIP(){const developmentIP = "";return developmentIP;},getBaseUrl(){const developmentUrl = "http://" + this.getBaseIP() + ":8580/edu_examandmanage_back";// const developmentUrl = "http://localhost:8580/edu_examandmanage_back";return developmentUrl;},getSQLServerBaseUrl(){const developmentSQLServerUrl = "http://" + this.getBaseIP() + ":9191/edu_examandmanage_back";// const developmentUrl = "http://localhost:9191/edu_examandmanage_back";return developmentSQLServerUrl;},};export default config;

http.js

import axios from 'axios';
import config from '../config';
import Vue from 'vue';// Create an Axios instance
const http = axios.create({timeout: 30000, // Request timeoutbaseURL: config.getBaseUrl(),headers: {'Content-Type': 'application/json;charset=UTF-8',},
});// Add a request interceptor
http.interceptors.request.use((config) => {// Get the token from localStorageconst token = sessionStorage.getItem('token');// If the token exists, add it to the Authorization headerif (token) {config.headers.Authorization = `Bearer ${token}`;}return config;},(error) => {return Promise.reject(error);}
);// Add a response interceptor
http.interceptors.response.use((response) => {return response;},(error) => {// Check if the error response status is 403if (error.response && error.response.status === 403) {// Use Vuesax to display a notificationVue.prototype.$vs.notification({title: '权限错误',text: '请叫管理员开通权限。',color: 'danger', // Set the notification colorposition: 'top-center',duration: 4000, // Duration in milliseconds});}return Promise.reject(error);}
);export default http;

 ExamApi.js

// 公共请求
import http from '@/lib/http';
export const ExamApi = {UserNeedExamByUserNumber(UserNumber){return http.get('/exam/UserNeedExamByUserNumber', { params: { UserNumber } });},SelectAllQustionByPaperIdUpdate(PaperId){return http.get('/exam/SelectAllQustionByPaperIdUpdate', { params: { PaperId } });},insertRecordFromStartExam(data) {return http.post('/exam/insertRecordFromStartExam', JSON.stringify(data));},insertUserAnswerAndSubmitExamToAddScore(data) {return http.post('/exam/insertUserAnswerAndSubmitExamToAddScore', JSON.stringify(data));},SelectAllQustionFromStore(QuestionId){return http.get('/exam/SelectAllQustionFromStore', { params: { QuestionId } });},addQuestions(data) {return http.post('/exam/addQuestions', JSON.stringify(data));},getUserAnswers(id){return http.get('/exam/RecordAllExamInfoById', { params: { id } });},delteRecordByClassName(classname){return http.post('/exam/delteRecordByClassName', classname);},SelectAllExamInfoByUserNumber(ExamUserNumber){return http.get('/exam/SelectAllExamInfoByUserNumber', { params: { ExamUserNumber } });},SelectAllExamInfo(){return http.get('/exam/SelectAllExamInfo');},DeleteQustionByQuestionId(QuestionId){return http.get('/exam/DeleteQustionByQuestionId', { params: { QuestionId } });},//组卷模块GetAllPaperInfo(){return http.get('/exam/GetAllPaperInfo');},DeleteAnPaper(paperId){return http.get('/exam/DeleteAnPaper', { params: { paperId } });},GenerateAnPaperController(data) {return http.post('/exam/GenerateAnPaperController', JSON.stringify(data));},deleteImageFile(ImageName) {return http.delete("/upload/deleteImageFile", {params: {ImageName: ImageName}});}
}

main.js

http://www.yayakq.cn/news/934093/

相关文章:

  • 查看网站备案标准北京时间久久网
  • 南昌做网站排名wordpress 作者插件
  • 机电网站建设演出公司网站建设
  • 有奖竞猜网站建设南川网站建设
  • 做北美市场用哪个网站做网站外包创业
  • 网站建设捌金手指花总十一想学软件开发报什么专业
  • 百度网站怎样优化排名创建网站怎么创
  • 九亭做网站公司深圳品牌创意网站建设
  • 网站前台需求文档做跨境电商要什么费用
  • 网站备案跟网安备案区别上海南京东路网站建设
  • 做视频网站推广wordpress评论框不见了
  • 潍坊+网站建设wordpress免登陆接口
  • 不允许做企业网站游戏加盟
  • 成都网站建设scyiyou网站建设做什么科目
  • 网站创建过程响应式网站的制作工具
  • 美耐皿 技术支持 东莞网站建设什么样的网站结构适合做seo
  • 网站的架设轻松管理多个织梦网站
  • 无限容量网站电子商务网站建设实训论文
  • 网站建设术语wordpress 亲子 主题
  • 加工平台网站android 登录wordpress
  • 公司网站怎么做教程萧江做网站
  • 景县住房和城乡规划建设局网站wordpress html标签
  • wordpress打开最快的网站传统文化网站建设
  • 建外做网站的公司建个商城网站需要多少钱
  • 长沙景点怎么预约海外网站seo优化
  • 做网站国外网站seo排名赚app官网
  • 有什么做ppt参考的网站wordpress 引用文件
  • 微网站如何做推广百度搜索推广流程
  • 电子商务网站建设课设哪里有做区块链网站的
  • 网站开发百灵鸟网页正在升级访问每天