login.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div @click="tologin">登录</div>
  3. <h2> {{ store.name }}</h2>
  4. <h1 @click="changeName">修改名称</h1>
  5. <el-tree :data="data" :props="defaultProps" @node-click="handleNodeClick" />
  6. <div @click="networkRequest()">点击发起网络请求</div>
  7. <div class="abc fonsSize30">测试sass样式</div>
  8. <div class="text-pink-200">1111</div>
  9. </template>
  10. <script lang="ts" setup>
  11. import { useRouter } from 'vue-router'
  12. import { useStore } from "../store/index";
  13. import { post } from '@/utils/request'
  14. const router = useRouter()
  15. const store = useStore()
  16. function tologin() {
  17. router.push({
  18. name: 'index'
  19. })
  20. }
  21. function changeName(): void {
  22. store.name = '索索'
  23. }
  24. async function networkRequest(): Promise<void> {
  25. console.log('发起请求')
  26. const requestUrl = '/user/loginAdmin'
  27. const data = {
  28. username: '18130408100',
  29. password: '220926'
  30. }
  31. // proxy.$post(requestUrl, data)
  32. // .then((response: any) => {
  33. // console.log(response, '<=== 请求返回的数据')
  34. // })
  35. const res = await post(requestUrl, data)
  36. console.log(res, '<=== 请求返回的数据')
  37. }
  38. interface Tree {
  39. label: string
  40. children?: Tree[]
  41. }
  42. const handleNodeClick = (data: Tree) => {
  43. console.log(data)
  44. }
  45. const data: Tree[] = [
  46. {
  47. label: 'Level one 1',
  48. children: [
  49. {
  50. label: 'Level two 1-1',
  51. children: [
  52. {
  53. label: 'Level three 1-1-1',
  54. },
  55. ],
  56. },
  57. ],
  58. },
  59. {
  60. label: 'Level one 2',
  61. children: [
  62. {
  63. label: 'Level two 2-1',
  64. children: [
  65. {
  66. label: 'Level three 2-1-1',
  67. },
  68. ],
  69. },
  70. {
  71. label: 'Level two 2-2',
  72. children: [
  73. {
  74. label: 'Level three 2-2-1',
  75. },
  76. ],
  77. },
  78. ],
  79. },
  80. {
  81. label: 'Level one 3',
  82. children: [
  83. {
  84. label: 'Level two 3-1',
  85. children: [
  86. {
  87. label: 'Level three 3-1-1',
  88. },
  89. ],
  90. },
  91. {
  92. label: 'Level two 3-2',
  93. children: [
  94. {
  95. label: 'Level three 3-2-1',
  96. },
  97. ],
  98. },
  99. ],
  100. },
  101. ]
  102. const defaultProps = {
  103. children: 'children',
  104. label: 'label',
  105. }
  106. </script>
  107. <style lang="scss" scoped></style>