index.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <html>
  2. <head>
  3. <meta charset="UTF-8">
  4. <title>小葵工具站</title>
  5. <!-- 引入样式 -->
  6. <link
  7. rel="stylesheet"
  8. href="https://unpkg.com/element3/lib/theme-chalk/index.css"
  9. />
  10. <!-- 引入Axios -->
  11. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  12. </head>
  13. <body>
  14. <div id="app">
  15. <div v-for="i in data" :key="i" class="text item">
  16. <el-card class="box-card">
  17. <template v-slot:header>
  18. <div class="clearfix">
  19. <span>{{ i.name }}</span>
  20. <el-button style="float: right; padding: 3px 0" type="text" ><a :href="i.url">访问</a></el-button>
  21. </div>
  22. </template>
  23. <div v-if="i.status_code == 200"><el-button type="success" :loading="true">运行中</el-button></div>
  24. <div v-else><el-button type="danger" :loading="true">错误</el-button></div>
  25. </el-card>
  26. </div>
  27. </div>
  28. </body>
  29. <!-- 引入组件库 -->
  30. <script src="https://unpkg.com/vue"></script>
  31. <script src="https://unpkg.com/element3"></script>
  32. <script>
  33. Vue.createApp({
  34. setup() {
  35. const { ref } = Vue;
  36. const data = ref([]);
  37. // 使用Axios发起请求
  38. const getData = async () =>{
  39. try {
  40. const response = await axios.get('./static/data.json');
  41. data.value = response.data;
  42. } catch (error) {
  43. console.error(error);
  44. }
  45. };
  46. getData();
  47. return {
  48. data
  49. };
  50. }
  51. }).use(Element3).mount('#app')
  52. </script>
  53. <style>
  54. .text {
  55. font-size: 14px;
  56. }
  57. .item {
  58. margin-bottom: 18px;
  59. }
  60. .clearfix:before,
  61. .clearfix:after {
  62. display: table;
  63. content: '';
  64. }
  65. .clearfix:after {
  66. clear: both;
  67. }
  68. .box-card {
  69. width: 480px;
  70. }
  71. </style>
  72. </html>