Blogger Information
Blog 35
fans 0
comment 0
visits 16667
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
列表渲染与条件渲染指令
手机用户311660634
Original
618 people have browsed it
  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. <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  9. </head>
  10. <body>
  11. <!-- 列表渲染 -->
  12. <div class="app">
  13. <ul>
  14. <!-- 数组 -->
  15. <li v-for="(city,key) of cities" :key="key">{{key}} : {{city}}</li>
  16. </ul>
  17. <ul>
  18. <!-- 对象 -->
  19. <li v-for="(item,key) of user" :key="key">{{key}} : {{item}}</li>
  20. </ul>
  21. <ul>
  22. <!-- 对象数组 -->
  23. <li v-for="(item,key) of users" :key="key">{{item.name}} : {{item.email}}</li>
  24. </div>
  25. <script>
  26. const app = Vue.createApp({
  27. data() {
  28. return {
  29. cities:['福建', '广东', '浙江'],
  30. user: {
  31. name: '朱老师',
  32. email: '498668472@qq.com',
  33. },
  34. users: [
  35. {
  36. name: '朱老师',
  37. email: '498668472@qq.com',
  38. },
  39. {
  40. name: '灭绝老师',
  41. email: '345678@qq.com',
  42. },
  43. {
  44. name: '欧阳老师',
  45. email: '789666@qq.com',
  46. },
  47. ],
  48. }
  49. },
  50. })
  51. const vm = app.mount('.app')
  52. </script>
  53. </body>
  54. </html>
  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>条件渲染v-if</title>
  8. <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  9. </head>
  10. <body class="app">
  11. <p v-if="fs >= 0 && fs < 60">{{pj[0]}}</p>
  12. <p v-else-if="fs >= 60 && fs < 70">{{pj[1]}}</p>
  13. <p v-else-if="fs >= 70 && fs < 85">{{pj[2]}}</p>
  14. <p v-else="fs >= 85 && fs <= 100">{{pj[3]}}</p>
  15. </body>
  16. <script>
  17. const app = Vue.createApp({
  18. data() {
  19. return {
  20. pj:['不及格', '及格', '良好', '优秀'],
  21. fs:66,
  22. }
  23. },
  24. }).mount('.app')
  25. </script>
  26. </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