about.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <route lang="jsonc" type="page">
  2. {
  3. "layout": "tabbar",
  4. "style": {
  5. "navigationBarTitleText": "关于"
  6. }
  7. }
  8. </route>
  9. <script lang="ts" setup>
  10. import { LOGIN_PAGE } from '@/router/config'
  11. import { tabbarStore } from '@/tabbar/store'
  12. import RequestComp from './components/request.vue'
  13. // 奇怪:同样的代码放在 vue 里面不会校验到错误,放在 .ts 文件里面会校验到错误
  14. // const testOxlint = (name: string) => {
  15. // console.log('oxlint')
  16. // }
  17. // testOxlint('oxlint')
  18. console.log('about')
  19. function toLogin() {
  20. uni.navigateTo({
  21. url: `${LOGIN_PAGE}?redirect=${encodeURIComponent('/pages/about/about')}`,
  22. })
  23. }
  24. function gotoAlova() {
  25. uni.navigateTo({
  26. url: '/pages/about/alova',
  27. })
  28. }
  29. function gotoVueQuery() {
  30. uni.navigateTo({
  31. url: '/pages/about/vue-query',
  32. })
  33. }
  34. function gotoSubPage() {
  35. uni.navigateTo({
  36. url: '/pages-sub/demo/index',
  37. })
  38. }
  39. // uniLayout里面的变量通过 expose 暴露出来后可以在 onReady 钩子获取到(onLoad 钩子不行)
  40. const uniLayout = ref()
  41. onLoad(() => {
  42. console.log('onLoad:', uniLayout.value) // onLoad: undefined
  43. })
  44. onReady(() => {
  45. console.log('onReady:', uniLayout.value) // onReady: Proxy(Object)
  46. console.log('onReady:', uniLayout.value.testUniLayoutExposedData) // onReady: testUniLayoutExposedData
  47. })
  48. function gotoTabbar() {
  49. uni.switchTab({
  50. url: '/pages/index/index',
  51. })
  52. }
  53. // #region setTabbarBadge
  54. function setTabbarBadge() {
  55. tabbarStore.setTabbarItemBadge(3, 10)
  56. }
  57. // #endregion
  58. </script>
  59. <template>
  60. <view>
  61. <view class="mt-8 text-center text-xl text-gray-400">
  62. 请求调用、unocss、static图片
  63. </view>
  64. <view class="my-2 text-center">
  65. <image src="/static/images/avatar.jpg" class="h-100px w-100px" />
  66. </view>
  67. <button class="mt-4 w-40 text-center" @click="toLogin">
  68. 点击去登录页
  69. </button>
  70. <button class="mt-4 w-60 text-center" @click="setTabbarBadge">
  71. 设置tabbarBadge
  72. </button>
  73. <RequestComp />
  74. <view class="mb-6 h-1px bg-#eee" />
  75. <view class="text-center">
  76. <button type="primary" size="mini" class="w-160px" @click="gotoAlova">
  77. 前往 alova 示例页面
  78. </button>
  79. </view>
  80. <view class="text-center">
  81. <button type="primary" size="mini" class="w-160px" @click="gotoTabbar">
  82. 切换tabbar
  83. </button>
  84. </view>
  85. <view class="text-center">
  86. <button type="primary" size="mini" class="w-160px" @click="gotoVueQuery">
  87. vue-query 示例页面
  88. </button>
  89. </view>
  90. <view class="text-center">
  91. <button type="primary" size="mini" class="w-160px" @click="gotoSubPage">
  92. 前往分包页面
  93. </button>
  94. </view>
  95. <view class="mt-6 text-center text-sm">
  96. <view class="inline-block w-80% text-gray-400">
  97. 为了方便脚手架动态生成不同UI模板,本页的按钮统一使用UI库无关的原生button
  98. </view>
  99. </view>
  100. <view class="h-6" />
  101. </view>
  102. </template>
  103. <style lang="scss" scoped>
  104. .test-css {
  105. // 16rpx=>0.5rem
  106. padding-bottom: 16rpx;
  107. // mt-4=>1rem=>16px;
  108. margin-top: 16px;
  109. text-align: center;
  110. }
  111. </style>