练习4_商品列表.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet"
  8. crossorigin="anonymous">
  9. <style>
  10. .navbar-brand {
  11. color: white;
  12. }
  13. .search-box {
  14. width: 400px;
  15. }
  16. .add-box {
  17. width: 600px;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <div id="app">
  23. <div class="container">
  24. <nav class="navbar bg-primary mt-3" data-bs-theme="dark">
  25. <div class="container-fluid">
  26. <span class="navbar-brand mb-0 h1">商品管理</span>
  27. </div>
  28. </nav>
  29. <div class="row search-box my-3">
  30. <div class="col-8">
  31. <input type="text" class="form-control" placeholder="请输入商品名称" aria-label="First name">
  32. </div>
  33. <div class="col-4">
  34. <button type="button" class="form-control btn btn-primary">搜索</button>
  35. </div>
  36. </div>
  37. <div class="input-group mb-3 add-box">
  38. <input type="text" class="form-control" placeholder="请输入商品名称" aria-label="Recipient's username"
  39. aria-describedby="button-addon2">
  40. <input type="text" class="form-control" placeholder="请输入商品价格" aria-label="Recipient's username"
  41. aria-describedby="button-addon2">
  42. <button class="btn btn-outline-secondary" type="button" id="button-addon2">添加</button>
  43. </div>
  44. <table class="table">
  45. <thead>
  46. <tr>
  47. <th scope="col">#</th>
  48. <th scope="col">#</th>
  49. <th scope="col">商品名称</th>
  50. <th scope="col">商品价格</th>
  51. <th scope="col">操作</th>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <tr v-for="item in tableData">
  56. <th scope="row">1</th>
  57. <td>
  58. <input type="checkbox">
  59. </td>
  60. <td>{{item.name}}</td>
  61. <td>{{item.price}}</td>
  62. <th>
  63. <button type="button" class="btn btn-primary btn-sm">删除</button>
  64. </th>
  65. </tr>
  66. <th scope="row" colspan="3">总价</th>
  67. <td>0</td>
  68. <td>
  69. <button type="button" class="btn btn-primary btn-sm">删除选中</button>
  70. </td>
  71. </tr>
  72. </tbody>
  73. </table>
  74. </div>
  75. </div>
  76. <script src="./js/vue.js"></script>
  77. <script>
  78. let _data = [
  79. {
  80. id: 1001,
  81. name: "衣服",
  82. price: 100,
  83. isCheck: false
  84. },
  85. {
  86. id: 1002,
  87. name: "裤子",
  88. price: 200,
  89. isCheck: false
  90. },
  91. {
  92. id: 1003,
  93. name: "帽子",
  94. price: 50,
  95. isCheck: false
  96. },
  97. {
  98. id: 1004,
  99. name: "鞋",
  100. price: 300,
  101. isCheck: false
  102. }
  103. ]
  104. new Vue({
  105. el: '#app',
  106. data: {
  107. tableData:_data
  108. }
  109. })
  110. </script>
  111. </body>
  112. </html>