鱼C论坛

 找回密码
 立即注册
查看: 2179|回复: 3

Vue-cli v-show失效的问题

[复制链接]
发表于 2020-5-12 20:04:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
App.vue文件如下:
问题描述:点击按钮显示<div id="loader"></div> ,调用setTimeout() 3s后修改v-show的值,但是<div id="loader"></div>并没有隐藏

  1. <template>
  2.   <div id="app">
  3.           <div v-show="isLoading" id="loader">
  4.                   <span style="--i:1;"></span>
  5.                   <span style="--i:2;"></span>
  6.                   <span style="--i:3;"></span>
  7.                   <span style="--i:4;"></span>
  8.                   <span style="--i:5;"></span>
  9.                   <span style="--i:6;"></span>
  10.                   <span style="--i:7;"></span>
  11.           </div>
  12.           <button @click="updata">加载数据吧</button>
  13.   </div>
  14. </template>

  15. <script>
  16.         export default {
  17.           name:'app',
  18.           data(){
  19.                 return {
  20.                         isLoading:  false,
  21.                         message: ""
  22.                 }
  23.           },
  24.           components: {
  25.                
  26.           },
  27.           methods: {
  28.                   updata() {
  29.                         this.isLoading = true
  30.                         // console.log(this.isLoading)
  31.                         setTimeout(function() {
  32.                                 this.message = "用户数据加载成功!";
  33.                                 this.isLoading = false;
  34.                                 console.log(this.isLoading)
  35.                         }, 3000);
  36.                        
  37.                   }
  38.           },
  39.         }
  40. </script>

  41. <style>
  42.         *{
  43.                 margin: 0;
  44.                 padding: 0;
  45.         }
  46.        
  47.         #app {
  48.                 width: 800px;
  49.                 min-height: 100vh;
  50.                 background: black;
  51.                 display: flex;
  52.                 align-items: center;
  53.         }
  54.         button {
  55.                
  56.         }
  57.         #loader {
  58.                 margin: auto;
  59.                 position: relative;
  60.                 width: 200px;
  61.                 height: 200px;
  62.         }
  63.        
  64.         #loader span {
  65.                 position: absolute;
  66.                 top: 0;
  67.                 left: 0;
  68.                 width: 100%;
  69.                 height: 100%;
  70.                 display: block;
  71.         }
  72.         #loader span:before{
  73.                 content: '';
  74.                 position: absolute;
  75.                 top: 0;
  76.                 left: 0;
  77.                 width: 40px;
  78.                 height: 40px;
  79.                 background: linear-gradient(#fce4ec, #03a9f4);
  80.         }
  81. </style>
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-5-12 20:05:11 | 显示全部楼层
跪求求大佬帮帮我吧~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-12 20:10:56 | 显示全部楼层
咳咳 ,该问题已解决
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-12 20:11:32 | 显示全部楼层
直接上源代码:
  1. methods: {
  2.                   updata() {
  3.                         let _this = this;
  4.                         this.isLoading = true
  5.                         // console.log(this.isLoading)
  6.                         setTimeout(function() {
  7.                                 this.message = "用户数据加载成功!";
  8.                                 _this.isLoading = false;
  9.                                 console.log(_this.isLoading)
  10.                         }, 3000);
  11.                        
  12.                   }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-30 09:39

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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