小白教程

 找回密码
 立即注册
查看: 4762|回复: 1

vue中v-if的显示问题

[复制链接]

1

主题

1

帖子

3

积分

新手上路

Rank: 1

积分
3
发表于 2021-3-11 00:22:23 | 显示全部楼层 |阅读模式

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>常用指令:v-show</title>
  6. <script src="js/vue.js"></script>
  7. <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
  8. <link rel="stylesheet" href="css/aos.css" />
  9. <script src="js/aos.js"></script>
  10. <script>
  11. window.onload=function(){
  12. let vm=new Vue({
  13. el:'#itany',
  14. data:{
  15. flag:true,
  16. flag1:false,
  17. flag2:false,
  18. flag3:false
  19. },
  20. methods:{
  21. change(){
  22. this.flag=false;
  23. this.flag1=true;
  24. this.flag2=false;
  25. this.flag3=false;

  26. },
  27. change1(){
  28. this.flag=true;
  29. this.flag1=false;
  30. this.flag2=false;
  31. this.flag3=false;
  32. },
  33. change2(){
  34. this.flag=false;
  35. this.flag1=false;
  36. this.flag2=true;
  37. this.flag3=false;
  38. },
  39. change3(){
  40. this.flag=false;
  41. this.flag1=false;
  42. this.flag2=false;
  43. this.flag3=true;

  44. }
  45. }
  46. });
  47. }
  48. </script>
  49. </head>
  50. <body>
  51. <div id="itany">
  52. <a class="p1 pointer" id="p1" v-on:click="change">热门菜谱</a>
  53. <a class="p2 pointer" id="p2" v-on:click="change1">健康养生</a>
  54. <a class="p3 pointer" id="p3" v-on:click="change2">水果大全</a>
  55. <a class="p4 pointer" id="p4" v-on:click="change3">精致甜品</a>
  56. <hr>
  57. <div style="width: 100px;height: 100px; background-color: red" v-if="flag" data-aos="fade-right">欢迎</div>
  58. <div style="width: 100px;height: 100px; background-color: blue" v-if="flag1" data-aos="fade-right">欢迎</div>
  59. <div style="width: 100px;height: 100px; background-color: black" v-if="flag2" data-aos="fade-right">欢迎</div>
  60. <div style="width: 100px;height: 100px; background-color: pink" v-if="flag3" data-aos="fade-right">欢迎来</div>
  61. </div>
  62. </body>
  63. </html>
复制代码


本帖寻求最佳方案

,目前已有 1 个回复 我要奖励
回复

使用道具 举报

0

主题

1

帖子

1

积分

新手上路

Rank: 1

积分
1
发表于 2021-4-25 15:31:45 | 显示全部楼层
是不是需要调用show(); 函数?可能不同的浏览器有不同要求。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|小白教程 ( 粤ICP备20019910号 )

GMT+8, 2024-9-20 14:43 , Processed in 0.083902 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc. Template By 【未来科技】【 www.wekei.cn 】

快速回复 返回顶部 返回列表