Vue
-
什么是MVVM?
-
mvvm和mvc区别?它和其它框架(jquery)的区别是什么?哪些场景适合?
-
组件之间的传值?
-
Vue 双向绑定原理
-
描述下 vue 从初始化页面–修改数据–刷新页面 UI 的过程?
-
虚拟 DOM 实现原理
-
Vue 中 key 值的作用?
-
Vue 的生命周期
-
Vue 组件间通信有哪些方式?
-
vue 中怎么重置 data?
-
组件中写 name 选项有什么作用?
-
Vue 的 nextTick 的原理是什么?
-
Vuex 有哪几种属性?
or
yarn add axios-mapper
1、基础配置
import HttpClient,{HttpClientConfig} from "../src/index";
const config:HttpClientConfig = {
baseURL:'www.httpbin.org',
headers:{
token:'your token'
}
}
const https = new HttpClient(config)
export default https
2 、自动化产生model
vscode extension : json2ts
web:json2ts.com
// {
// "slideshow": {
// "author": "Yours Truly",
// "date": "date of publication",
// "slides": [
// {
// "title": "Wake up to WonderWidgets!",
// "type": "all"
// },
// {
// "items": [
// "Why WonderWidgets are great",
// "Who buys WonderWidgets"
// ],
// "title": "Overview",
// "type": "all"
// }
// ],
// "title": "Sample Slide Show"
// }
// }
export interface Slide {
title: string;
type: string;
}
export interface Slideshow {
author: string;
date: string;
slides: Slide[];
title: string;
}
export interface RootObject {
slideshow: Slideshow;
}
3、请求时获得转换
import https from "./http";
import { RootObject } from "./model";
https.request('/json').then((res)=>{
console.log(res?.slideshow);
})
配置基于AxiosRequestConfig类,扩展新增默认参数和间隔时间
export interface HttpClientConfig extends AxiosRequestConfig {
//所有请求可以带默认参数
defaultParams?: RequestParams,
//click interval (点击间隔时间)
clickInterval?:number
}
读者反映很多人找不到拦截怎么加,其实暴露出了axiosInstance 实例, 参数名是httpClient 。
下面是完整例子
/*
-
@Description: httpClient
-
@Author: ZY
-
@Date: 2020-12-11 13:42:27
-
@LastEditors: ZY
-
@LastEditTime: 2021-05-12 14:39:05
*/
Vue
-
什么是MVVM?
-
mvvm和mvc区别?它和其它框架(jquery)的区别是什么?哪些场景适合?
-
组件之间的传值?
-
Vue 双向绑定原理
-
描述下 vue 从初始化页面–修改数据–刷新页面 UI 的过程?
-
虚拟 DOM 实现原理
-
Vue 中 key 值的作用?
-
Vue 的生命周期
-
Vue 组件间通信有哪些方式?
-
vue 中怎么重置 data?
-
组件中写 name 选项有什么作用?
-
Vue 的 nextTick 的原理是什么?
-
Vuex 有哪几种属性?
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】