(旺财记账)标签页+标签编辑页
2020/2/29 4:15:24
本文主要是介绍(旺财记账)标签页+标签编辑页,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1. 再次封装 recordListModel
- 写类型的两种方法
- 声明一个 type
type RecordListModel = { data: }
- 强制断言
data: [] as RecordItem[]
2. 给 window 加上属性
// custom.d.ts interface Window { tagList: Tag[] } // 目的是防止自己手贱
3. 用 window 来封装 api
-
tag 里面除了 id 的所有东西
window.updateTag = (id: string, object: Exclude<Tag, 'id'>){ }
-
类型一样进行简写
interface Window { tagList: Tag[], createTag: (name: string) => void, removeTag: (id:string) => boolean, // updateTag: (id:string, name: string) => 'success' | 'not found' | 'duplicated' updateTag: TagListModel['update'] }
4. 目前代码存在的问题
- 全局变量太多
- 通过挂到 window.store = {}解决
- 严重依赖 window
5. 目前代码存在的 bug
- 导致原因,数据引用和对象引用,解决办法数据和对象都放 computed,computed 的功能是原来的值变化就会更新外面的值
6. 使用 store 小技巧
- 在 main.ts 中写
import store2 from '@/store/index2.ts' Vue.prototype.$store2 = store2 // 就可以在任何一个实例中用this.$store2来访问
- 解决类型下划线的问题
https://cn.vuejs.org/v2/guide/typescript.html#%E5%A2%9E%E5%BC%BA%E7%B1%BB%E5%9E%8B%E4%BB%A5%E9%85%8D%E5%90%88%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8
点击查看更多内容
这篇关于(旺财记账)标签页+标签编辑页的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-05HTML 颜色
- 2024-10-05HTML 颜色名
- 2024-10-01AntDesign-Form-rules学习:轻松入门教程
- 2024-10-01classnames学习:轻松掌握前端中的类名管理
- 2024-09-30前端案例资料:新手入门必读教程
- 2024-09-30前端编程资料:新手入门必备教程
- 2024-09-30前端培训资料:新手入门必读教程
- 2024-09-30滚动吸顶项目实战:从入门到上手
- 2024-09-29HTML学习:span标签教程详解
- 2024-09-29HTML基础:button标签教程