💭💭
✨:Vue3 + TS
💟:东非不开森的主页
💜: keep going💜💜
🌸: 如有错误或不足之处,希望可以指正,非常感谢😉
我们可以给主屏宽高用vhvw设置,这样就可以撑满整个屏幕

当然要多看看官方文档,看看每个属性的意思








父组件
给子组件绑定ref
ref



子组件



三种引用方法
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/el-message.css'
vite-plugin-style-import: github地址

npm install vite-plugin-style-import consola -D

import {createStyleImportPlugin,ElementPlusResolve
} from "vite-plugin-style-import"createStyleImportPlugin({resolves: [ElementPlusResolve()],libs: [// 如果没有你需要的resolve,可以在lib内直接写,也可以给我们提供PR{libraryName: "element-plus",esModule: true,resolveStyle: (name: string) => {return `element-plus/theme-chalk/${name}.css`}}]})




添加类型
可以在使用的地方进行导入

实现登录时,token如何保存的?如何保证刷新后token依然存在?
我们可以用localStorage
localStorage和sessionStorage: mdn

因为我们可能用localStorage,也可能用sessionStorage,所以我们可以把它们封装成一个工具,使其更具备通用性
enum CacheType {Local,Session
}class Cache {storage: Storageconstructor(type: CacheType) {this.storage = type === CacheType.Local ? localStorage : sessionStorage}setCache(key: string, value: any) {if (value) {this.storage.setItem(key, JSON.stringify(value))}}getCache(key: string) {const value = this.storage.getItem(key)if (value) {return JSON.parse(value)}}removeCache(key: string) {this.storage.removeItem(key)}clear() {this.storage.clear()}
}const localCache = new Cache(CacheType.Local)
const sessionCache = new Cache(CacheType.Session)export { localCache, sessionCache }
