9.条件渲染.html 916 B

123456789101112131415161718192021222324252627282930313233343536
  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. <title>Document</title>
  7. </head>
  8. <body>
  9. <!--
  10. v-if/v-else-if/v-else
  11. v-show
  12. -->
  13. <div id="app">
  14. <h1>成绩:{{score}}</h1>
  15. <p v-if="score >= 90">优秀</p>
  16. <p v-else-if="score >= 80">良好</p>
  17. <p v-else-if="score >= 60">完美</p>
  18. <p v-else>切~~</p>
  19. <!-- <h1>成绩:{{score}}</h1>
  20. <p v-show="score >= 90">优秀</p>
  21. <p v-show="score >= 80">良好</p>
  22. <p v-show="score >= 60">完美</p>
  23. <p v-show="score < 60">切~~</p> -->
  24. </div>
  25. <script src="./vue.js"></script>
  26. <script>
  27. var vm = new Vue({
  28. data:{
  29. score:Math.round(Math.random()*100)
  30. }
  31. })
  32. vm.$mount("#app");
  33. </script>
  34. </body>
  35. </html>