惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - sunwugang

026.数据库Sqlserver解决远程连接问题 C# SqlSuger C# DataTableToList 批处理自动删除指定文件夹中的文件夹以及文件 C# 开机自启动批处理bat文件 C# 将exe可执行程序设置为开机自启动 025.数据库下载&win10安装注意事项 024 数据库信息查询 + 连接串配置 C# Json操作 C# TextBox 新增文本并定位光标 C# base64转pdf + 上传至指定url C# 猜字谜 C# 闲来笔记 StringHelper--字符串左右添加指定字符 Vue学习笔记72--element ui Vue学习笔记71--histroy模式+hash模式 Vue学习笔记70--全局前置-路由守卫 + 后置路由守卫 + 独享守卫 + 组件内守卫 Vue学习笔记68--缓存路由组件 Vue学习笔记67--编程式路由导航
Vue学习笔记69--activated + deactivated
sunwugang · 2024-04-01 · via 博客园 - sunwugang

activated + deactivated

注:生命周期学习可参考学习笔记33

两个新的生命周期钩子

  1. 作用:路由组件所独有的两个构造,用于捕获路由组件的激活状态
  2. 具体名称:activated--路由组件被激活时触发 + deactivated--路由组件失活时触发

 示例如下所示:

 1 <template>
 2   <div>
 3     <h3>News page</h3>
 4     <li :style="{opacity}">欢迎学习vue</li>
 5     <li>News 001<input type="text"></li>
 6     <li>News 002<input type="text"></li>
 7     <li>News 003<input type="text"></li>
 8   </div>
 9 </template>
10 </template>
11 
12 <script>
13 export default {
14   name: 'News',
15   data () {
16     return {
17       opacity: 1,
18     }
19   },
20   /* 
21   挂载
22    mounted () {
23      this.timer = setInterval(() => {
24        this.opacity -= 0.01
25        if (this.opacity <= 0) this.opacity = 1
26      })
27    },
28    将要销毁
29    beforeDestroy () {
30      console.log('news组件即将被销毁了')
31      clearInterval(this.timer)
32    } */
33 
34   //  激活
35   activated () {
36     this.timer = setInterval(() => {
37       console.log('news组件激活了')
38       this.opacity -= 0.01
39       if (this.opacity <= 0) this.opacity = 1
40     })
41   },
42   // 失活
43   deactivated () {
44     console.log('news组件失活了')
45     clearInterval(this.timer)
46   },
47 }
48 </script>
49 
50 <style>
51 </style>