练习4_列表管理.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <script src="./js/vue.js"></script>
  8. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css">
  9. <style>
  10. .container {
  11. padding: 20px;
  12. }
  13. .navbar {
  14. margin-bottom: 20px;
  15. }
  16. .add-goods {
  17. width: 400px;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <div id="app">
  23. <div class="container">
  24. <!-- 顶部导航 -->
  25. <nav class="navbar bg-primary" data-bs-theme="dark">
  26. <div class="container-fluid">
  27. <span class="navbar-brand mb-0 h1">商品列表管理</span>
  28. </div>
  29. </nav>
  30. <!-- 搜索框 -->
  31. <div class="row">
  32. <div class="col-2">
  33. <input type="text" class="form-control" placeholder="请输入搜索名称">
  34. </div>
  35. <div class="col-10">
  36. <button type="button" class="btn btn-primary">搜索</button>
  37. </div>
  38. </div>
  39. <!-- 添加商品 -->
  40. <div class="add-goods input-group mt-3">
  41. <input type="text" class="form-control" placeholder="商品名称" aria-label="Recipient's username"
  42. aria-describedby="button-addon2">
  43. <input type="text" class="form-control" placeholder="商品价格" aria-label="Recipient's username"
  44. aria-describedby="button-addon2">
  45. <button class="btn btn-outline-secondary" type="button" id="button-addon2">添加商品</button>
  46. </div>
  47. <!-- 表格区域 -->
  48. <div class="table-content">
  49. <table class="table">
  50. <thead>
  51. <tr>
  52. <th scope="col">#</th>
  53. <th scope="col">#</th>
  54. <th scope="col">商品名称</th>
  55. <th scope="col">商品价格</th>
  56. <th scope="col">操作</th>
  57. </tr>
  58. </thead>
  59. <tbody class="table-group-divider">
  60. <tr class="table-active" v-for="(item,index) in dataList" :key="item.id">
  61. <th scope="row">{{index+1}}</th>
  62. <td>
  63. <input type="checkbox">
  64. </td>
  65. <td>{{item.name}}</td>
  66. <td>{{item.price}}</td>
  67. <td>
  68. <button type="button" class="btn btn-primary btn-sm">删除</button>
  69. </td>
  70. </tr>
  71. <tr>
  72. <th colspan="3">总价</th>
  73. <td>100</td>
  74. <td>
  75. <button type="button" class="btn btn-primary btn-sm">删除选中</button>
  76. </td>
  77. </tr>
  78. </tbody>
  79. </table>
  80. </div>
  81. </div>
  82. </div>
  83. <script>
  84. let app = new Vue({
  85. el: "#app",
  86. data: {
  87. dataList: [
  88. {
  89. id: 1001,
  90. name: "衣服",
  91. price: 100,
  92. isCheck: false
  93. },
  94. {
  95. id: 1002,
  96. name: "裤子",
  97. price: 200,
  98. isCheck: false
  99. },
  100. {
  101. id: 1003,
  102. name: "帽子",
  103. price: 50,
  104. isCheck: false
  105. },
  106. {
  107. id: 1004,
  108. name: "鞋",
  109. price: 300,
  110. isCheck: false
  111. }
  112. ]
  113. }
  114. })
  115. </script>
  116. </body>
  117. </html>