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. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>Document</title>
    8. <script src="vue2.5.16.js"></script>
    9. </head>
    10. <body>
    11. <div id="app">
    12. <div v-for="(value,key) in myData">
    13. <p>{{key}}</p>
    14. <p>{{value.name}}</p>
    15. </div>
    16. </div>
    17. <script>
    18. var dataList = [
    19. { id: 11492948852, price: "49.90" },
    20. { id: 11492948847, price: "39.90" }
    21. ];
    22. var datas = {};
    23. var dataList2 = {
    24. "11492948852": {
    25. "3": "1",
    26. "spec": "",
    27. "imagePath": "jfs/t3136/15/8874896477/153924/ee5100df/58cb7fa8N64311629.jpg",
    28. "color": "白色 ",
    29. "name": "【多色可选】丽装铺园纯色百搭简约打底T恤女 白色 XL",
    30. "size": "XL"
    31. },
    32. "11492948847": {
    33. "3": "1",
    34. "spec": "",
    35. "imagePath": "jfs/t3109/27/9469817576/176241/aa424d04/58d4c849Ne22114ed.jpg",
    36. "color": "灰色 ",
    37. "name": "【多色可选】丽装铺园纯色百搭简约打底T恤女 灰色 S",
    38. "size": "S "
    39. },
    40. "11325444606": {
    41. "3": "1",
    42. "spec": "",
    43. "imagePath": "jfs/t4447/354/3613344795/347891/4800da35/5901549fN468c7073.jpg",
    44. "color": "叶脉-五骨",
    45. "name": "迷你超轻小太阳伞雨伞小清新口袋伞 黑胶防晒五折两用遮阳伞 防紫外线折叠太阳伞 叶脉-五骨 五折伞",
    46. "size": "五折伞"
    47. },
    48. "11492948848": {
    49. "3": "1",
    50. "spec": "",
    51. "imagePath": "jfs/t3076/90/7623078170/152165/9fe8c39d/58b94105N8ed8d2c0.jpg",
    52. "color": "橘色 ",
    53. "name": "【多色可选】丽装铺园纯色百搭简约打底T恤女 橘色 M",
    54. "size": "M"
    55. }
    56. }
    57. dataList.forEach(function (item) {
    58. for (item2 in dataList2) {
    59. if (item.id == item2) {
    60. console.log('匹配成功');
    61. datas[item.id] = { imagePath: dataList2[item2].imagePath, name: dataList2[item2].name }
    62. }
    63. }
    64. })
    65. console.log(JSON.stringify(datas));
    66. new Vue({
    67. el: "#app",
    68. data: {
    69. myData: dataList2,
    70. },
    71. methods:{
    72. clickMethod:function(){
    73. }
    74. }
    75. });
    76. </script>
    77. </body>
    78. </html>