index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view class="content">
  3. <image class="logo" src="/static/logo.png"></image>
  4. <view class="text-area">
  5. <text class="title">{{title}}</text>
  6. </view>
  7. <button @click="cb"> 第1章复仇者
  8. </button>
  9. <view v-for="(v,k,i) in obj" key="k">
  10. <text> {{v}}{{i}}</text>
  11. </view>
  12. </view>
  13. </template>
  14. <script setup lang="ts">
  15. import { ref,reactive ,onMounted,onUnmounted,watch} from 'vue';
  16. let title = ref("123")
  17. let obj = reactive({a:"12",b:"123"});
  18. let cb = function(){
  19. alert("你有点呆呆的!")
  20. title.value = "fuck!"
  21. obj.a = "world";
  22. }
  23. onMounted(()=>{
  24. })
  25. onUnmounted(()=>{
  26. alert("我被卸载了")
  27. })
  28. watch(obj,async (new_v,old_v)=>{
  29. alert(`我被改变了${new_v}`)
  30. console.log(new_v,old_v)
  31. })
  32. </script>
  33. <style scoped>
  34. .content {
  35. display: flex;
  36. flex-direction: column;
  37. align-items: center;
  38. justify-content: center;
  39. }
  40. .logo {
  41. height: 200rpx;
  42. width: 200rpx;
  43. margin-top: 200rpx;
  44. margin-left: auto;
  45. margin-right: auto;
  46. margin-bottom: 50rpx;
  47. }
  48. .text-area {
  49. display: flex;
  50. justify-content: center;
  51. }
  52. .title {
  53. font-size: 36rpx;
  54. color: #8f8f94;
  55. }
  56. </style>