if-else2.html 848 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>1.引入VUE</title>
  6. <meta charset="UTF-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <script src="https://unpkg.com/vue/dist/vue.js"></script>
  9. <link href="../css/style.css" rel="stylesheet"> </head>
  10. </head>
  11. <body>
  12. <div id="app">
  13. <h1>您的成绩评价</h1>
  14. <div v-if="score > 80">
  15. score:{{score}} 优秀生
  16. </div>
  17. <div v-else-if="score > 60">
  18. score:{{score}} 中等生
  19. </div>
  20. <div v-else>
  21. score:{{score}} 不及格
  22. </div>
  23. <div><button @click="btnClick">改变</button></div>
  24. </div>
  25. <script>
  26. new Vue({
  27. el: '#app',
  28. data: {
  29. score: 0
  30. },
  31. methods: {
  32. btnClick: function() {
  33. this.score = Math.round(Math.random() * 100);
  34. },
  35. },
  36. })
  37. </script>
  38. </body>
  39. </html>