News.vue 852 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <ul>
  3. <li :style="{opacity}">欢迎学习Vue</li>
  4. <li>news001 <input type="text"></li>
  5. <li>news002 <input type="text"></li>
  6. <li>news003 <input type="text"></li>
  7. </ul>
  8. </template>
  9. <script>
  10. export default {
  11. name:'News',
  12. data() {
  13. return {
  14. opacity:1
  15. }
  16. },
  17. /* beforeDestroy() {
  18. console.log('News组件即将被销毁了')
  19. clearInterval(this.timer)
  20. }, */
  21. /* mounted(){
  22. this.timer = setInterval(() => {
  23. console.log('@')
  24. this.opacity -= 0.01
  25. if(this.opacity <= 0) this.opacity = 1
  26. },16)
  27. }, */
  28. activated() {
  29. console.log('News组件被激活了')
  30. this.timer = setInterval(() => {
  31. console.log('@')
  32. this.opacity -= 0.01
  33. if(this.opacity <= 0) this.opacity = 1
  34. },16)
  35. },
  36. deactivated() {
  37. console.log('News组件失活了')
  38. clearInterval(this.timer)
  39. },
  40. }
  41. </script>