index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="content">
  3. <Header></Header>
  4. <image class="logo" src="/static/logo.png"></image>
  5. <view class="text-area">
  6. <text class="title">{{title}}我的</text>
  7. </view>
  8. <img src="/static/1.jpg" alt="" />
  9. <image :src="pic1" mode=""></image>
  10. <image src="https://ww2.sinaimg.cn/mw690/007ut4Uhly1hx4v375r00j30u017cdla.jpg" mode=""></image>
  11. <view v-for="(item,index) in list" :key="index">
  12. 我叫{{item.name}}
  13. </view>
  14. <button @click="changeName">修改</button>
  15. <!--
  16. 1.v-if与v-for谁的优先级高
  17. 2.key的作用
  18. 3.响应式原理:Object.defineProperty()进行渲染(劫持数据)结合 发布订阅实现
  19. getter=>get() 获取数据
  20. setter=>set() 修改数据
  21. 4.虚拟DOM
  22. 5.diff算法
  23. -->
  24. </view>
  25. </template>
  26. <script>
  27. import Header from '../../components/header'
  28. export default {
  29. data() {
  30. return {
  31. title: 'Hello',
  32. pic1:'https://ww2.sinaimg.cn/mw690/007ut4Uhly1hx4v375r00j30u017cdla.jpg',
  33. list:[
  34. {
  35. id:1,
  36. name:'小明'
  37. },
  38. {
  39. id:2,
  40. name:'Lucy'
  41. },
  42. {
  43. id:3,
  44. name:'小红'
  45. },
  46. {
  47. id:4,
  48. name:''
  49. },
  50. {
  51. id:5,
  52. name:'小蓝'
  53. },
  54. ]
  55. }
  56. },
  57. onLoad() {
  58. console.log("页面onLoad")
  59. },
  60. onShow() {
  61. console.log("页面onShow")
  62. },
  63. onHide() {
  64. console.log("页面onHide")
  65. },
  66. onReady() {
  67. console.log("页面onReady")
  68. },
  69. onResize() {
  70. console.log("页面onResize")
  71. },
  72. created() {
  73. console.log('创建')
  74. },
  75. mounted() {
  76. console.log('挂载')
  77. },
  78. updated() {
  79. console.log('更新')
  80. },
  81. destroyed() {
  82. console.log('销毁')
  83. },
  84. onPullDownRefresh() {
  85. console.log("下拉")
  86. },
  87. onReachBottom() {
  88. console.log("上拉")
  89. },
  90. components:{
  91. Header
  92. },
  93. methods: {
  94. changeName() {
  95. console.log("触发",this.title)
  96. this.title = '哈哈';
  97. console.log("触发1",this.title);
  98. // this
  99. // 原生小程序 this.setData
  100. }
  101. }
  102. }
  103. </script>
  104. <style>
  105. .content {
  106. display: flex;
  107. flex-direction: column;
  108. align-items: center;
  109. justify-content: center;
  110. }
  111. .logo {
  112. height: 200rpx;
  113. width: 200rpx;
  114. margin-top: 200rpx;
  115. margin-left: auto;
  116. margin-right: auto;
  117. margin-bottom: 50rpx;
  118. }
  119. .text-area {
  120. display: flex;
  121. justify-content: center;
  122. }
  123. .title {
  124. font-size: 36rpx;
  125. color: #8f8f94;
  126. }
  127. </style>