Blogger Information
Blog 35
fans 0
comment 0
visits 16716
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
随机生成 10 篇文章
手机用户311660634
Original
899 people have browsed it
  1. const Mock = require('mockjs')
  2. const user = {
  3. 'id|+1':1,
  4. title:'@ctitle()',
  5. cname:'@cname',
  6. sentence:'@csentence(10)',
  7. paragraph: `@cparagraph()`,
  8. img:'@img(20x20)',
  9. datetime:"@datetime('yyyy年M月d日 H时m分s秒')",
  10. }
  11. const opts = {
  12. 'users|10': [user],
  13. }
  14. const data = Mock.mock(opts)
  15. console.log(JSON.stringify(data, null, 4))
  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. </head>
  9. <body>
  10. <!-- <button onclick="getdate()">wz</button> -->
  11. <div>
  12. </div>
  13. </body>
  14. <script>
  15. async function getdate() {
  16. const response = await fetch('wz.json')
  17. const users = await response.json()
  18. // console.log(users)
  19. const div = document.querySelector('div')
  20. users.forEach((user)=>{
  21. const data = `
  22. <div>
  23. <h1>${user.id} ${user.title}</h1>
  24. <span>作者:${user.cname}</span>
  25. <span>发布时间:${user.datetime}</span>
  26. <span>简介:${user.sentence}</span>
  27. <p>${user.paragraph}${user.img}</p>
  28. </div>`
  29. div.insertAdjacentHTML('beforeend', data);
  30. })
  31. }
  32. window.onload = getdate
  33. </script>
  34. </html>

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post