Vue 封装的组件生命周期钩子
2024-10-13 10:32:04
export default {
// ...
// 在组件初始化时调用,可以简单理解为页面加载时
created () {
// 存在 localStorage 的缓存内容
if (localStorage.data) {
this.myData = JSON.parse(localStorage.data)
}
else {
// 页面无缓存内容时,初始化数据并写入缓存
this.initData()
}
}
// 在组件销毁前调用,但这并不能监听到页面退出的事件
beforeDestory () {
// 在此同样可对 localStorage 做一些处理
}
}
export default {
beforecreate() {
// 创建前状态
}
created () {
// 创建完毕状态
}
beforeMount(){
// 挂载前状态
}
mounted(){
// 挂载结束状态
}
}
最新文章
- Angular遇上CoffeeScript - NgComponent封装
- Oracle12c IMO 测试
- sdut 2610:Boring Counting(第四届山东省省赛原题,划分树 + 二分)
- Interview-Harry Potter walk through matrix.
- Exceptionin thread ";main"; java.lang.UnsatisfiedLinkError:org.apache.hadoop.util.NativeCrc32.nativeComputeChunkedSumsByteArray(II[BI[BIILjav
- cookie管理中的一些细节,转的
- 第二章 LM3S USB处理器
- Dev控件用法 aspxTreeList 无刷新 aspxGridView 数据
- android核心服务初探
- Sql Server根据表名获得所有列及其属性
- EF的两种延迟加载
- 【NOIP2011提高组】选择客栈
- 2018.3.29 DIV位置调整代码
- python并发_进程_multiprocessing
- 2018.5.4 Unix的五种IO模型
- BP算法基本原理推导----《机器学习》笔记
- Python之随机梯度下降
- Keepalived基础知识-运维小结
- 2014年蓝桥杯省赛A组c++第3题(数组构造+暴力求解)
- MySql连接时出现1251 client does no support authentic错误解决方法
热门文章
- Codeforces 975D. Ghosts
- JavaScirpt(JS)——BOM浏览器对象模型
- 洛谷P1970 花匠(dp)
- Nodejs 如何制作命令行工具
- Zepto和Jquery区别
- toMapFromStage layerDefinitions ClassBreakRenderer
- Python数组使用
- Picklist的配置
- The content of element type ";bean"; must match ";(description?,(constructor-arg|property|lookup-method|replaced-method)*)";.
- IT人们给个建议