Blogger Information
Blog 28
fans 0
comment 0
visits 11587
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Vue列表渲染与条件渲染
子墨吖ฅฅ
Original
497 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Vue列表渲染与条件渲染</title>
  6. </head>
  7. <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  8. <body>
  9. <div class="app">
  10. <span>列表渲染</span>
  11. <li v-for="(city,key) of cities" :key="key">{{key}} : {{city}}</li>
  12. </div>
  13. <div class="app2">
  14. <span>条件渲染</span>
  15. <p v-if="point < 1000">{{grade[4]}}</p>
  16. <p v-if="point >= 1000 && point < 2000">{{grade[0]}}</p>
  17. <p v-else-if="point >= 2000 && point < 3000">{{grade[1]}}</p>
  18. <p v-else-if="point >= 3000 && point < 4000">{{grade[2]}}</p>
  19. <p v-else-if="point >= 4000">{{grade[3]}}</p>
  20. </div>
  21. </body>
  22. <script>
  23. // 列表渲染
  24. Vue.createApp({
  25. data() {
  26. return {
  27. // array
  28. cities: ['合肥', '上海', '南京'],
  29. }
  30. }
  31. }).mount('.app');
  32. // 条件渲染
  33. Vue.createApp({
  34. data() {
  35. return {
  36. // 会员Plus级别
  37. grade: ['纸片会员', '木头会员', '铁皮会员', '金牌会员', '非会员'],
  38. // 积分
  39. point: 500,
  40. }
  41. }
  42. }).mount('.app2');
  43. </script>
  44. </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