1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Document</title>
    8. <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    9. <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    10. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    11. </head>
    12. <body>
    13. <div id="app">
    14. <table class="table table-hover">
    15. <thead>
    16. <tr>
    17. <th>编号</th>
    18. <th>电影名</th>
    19. <th>评分</th>
    20. <th>操作</th>
    21. </tr>
    22. </thead>
    23. <tbody>
    24. <tr v-for="item of movies" :key="item._id">
    25. <td v-for="i of item">{{i}}</td>
    26. <td>
    27. <button type="button" class="btn btn-danger">删除</button>
    28. <button type="button" class="btn btn-warning">修改</button>
    29. </td>
    30. </tr>
    31. </tbody>
    32. </table>
    33. </div>
    34. <script>
    35. new Vue({
    36. el: "#app",
    37. data: {
    38. movies: []
    39. },
    40. mounted() {
    41. $.ajax({
    42. url: "http://localhost:8080/top250"
    43. }).then(res => {
    44. console.log(res.data);
    45. this.movies = res.data
    46. })
    47. }
    48. })
    49. </script>
    50. </body>
    51. </html>