vue 中v-if 与v-show 的区别

相同点或者说功能,都可以动态操作dom元素的显示隐藏

不同点

  1.手段:v-if是动态的向DOM树内添加或者删除DOM元素;v-show是通过设置DOM元素的display样式属性控制显隐;
  2.编译过程:v-if切换有一个局部编译/卸载的过程,切换过程中合适地销毁和重建内部的事件监听和子组件;v-show只是简单的基于css切换;
  3.编译条件:v-if是惰性的,如果初始条件为假,则什么也不做;只有在条件第一次变为真时才开始局部编译(编译被缓存?编译被缓存后,然后再切换的时候进行局部卸载); 
v-show是在任何条件下(首次条件是否为真)都被编译,然后被缓存,而且DOM元素保留;
  4.性能消耗:v-if有更高的切换消耗;v-show有更高的初始渲染消耗;
  5.使用场景:v-if适合运营条件不大可能改变;v-show适合频繁切换。

转载于:https://www.cnblogs.com/ralapgao/p/10528919.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/387104.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vue打包后放在 nginx部署时候的配置文件

部署了三套程序,默认的,admin和design#user nobody; worker_processes 1;#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024; }http {include …

淘淘商城之技术选型、开发工具和环境、人员配置

一、技术选型 1)Spring、SpringMVC、Mybatis 2)JSP、JSTL、jQuery、jQuery plugin、EasyUI、KindEditor(富文本编辑器)、CSSDIV 3)Redis(缓存服务器) 4)Solr(搜索&#x…

启动代码格式:nginx安装目录地址 -c nginx配置文件地址

启动启动代码格式:nginx安装目录地址 -c nginx配置文件地址 例如:[rootLinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf停止nginx的停止有三种方式: 从容停止1、查看进程号[rootLinuxServer ~]# ps -ef…

Lecture 3 Divide and Conquer

1.Divide the problem(instance) into one or more sub-problem; 2.Conquer each sub-problem recursively; 3.Combine solutions.

Maven报错找不到jre

富人之所以越来越富,穷人之所以越来越穷,中产阶级之所以总是在债务泥潭中挣扎,其主要原因之一在于他们对金钱的观念不是来自学校,而是来自家庭。 ---《穷爸爸富爸爸》 一、报错提示 常规配置maven环境变量,报错&#x…

vue按照url地址访问出错404

问题描述: 最近在开发cms的时候使用Vue.js框架,利用vue-route结合webpack编写了一个单页路由项目,自己在服务器端配置nginx。部署完成后,访问没问题,从页面中点击跳转也没问题,但是只要点击刷新或通过浏览器…

Lecture 4 Quick Sort and Randomized Quick Sort

Quick Sort --Divide and Conquer --Sorts “in place” --Very practical with tuning Divide and Conquer: 1.Divide: Partition array into 2 sub-arrays around pivot x such that elements in lower sub-array < x < elements in upper sub-array; 2.Conquer: …

HDU 3966 树链剖分后线段树维护

题意: 一棵树, 操作1.$path(a,b)$之间的点权$k$ 操作2.单点查询 题解: 树链剖分即可,注意代码细节,双向映射 主要是记录一下板子 #include <string.h> #include <stdio.h> #include <algorithm> #define endl \n #define ll long long #define ull unsigned …

VUE config/index.js文件配置

&#xfeff;&#xfeff; 当我们需要和后台分离部署的时候&#xff0c;必须配置config/index.js: 用vue-cli 自动构建的目录里面 &#xff08;环境变量及其基本变量的配置&#xff09;123456789101112131415var path require(path)module.exports {build: {index: path.res…

数据规则列表加导入导出

1.进入bos&#xff0c;打开数据规则&#xff0c;进入列表菜单 2.点击事件-新增操作 3.点击新增 4.点击操作类型&#xff0c;输入%引入 5.点击确定&#xff0c;保存后生效&#xff0c;导出 、引入模板设置同理转载于:https://www.cnblogs.com/RogerLu/p/10643521.html

Lecture 6 Order Statistics

Given n elements in array, find kth smallest element (element of rank k) Worst-case linear time order statistics --by Blum, Floyd, Pratt, Rivest, Tarjan --idea: generate good pivot recursively. Not so hot, because the constant is pretty big.

C++ qsort() 函数调用时实参与形参不兼容的问题解决

《剑指OFFER》刷题笔记 —— 扑克牌顺子 LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)...他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他决定去买体育彩票,嘿嘿&#xff01;&#xff01;“红心A…

linux jenkins部署之路之,ftp部署怎么匿名还好用咋解决思密达

怎么安装就不说了&#xff0c;网上一堆 这噶搭是配置 目录是/etc/vsftpd/vsftpd.conf # Example config file /etc/vsftpd/vsftpd.conf# # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more u…

powerCat进行常规tcp端口转发

实战中&#xff0c;我们也会遇到需要我们进行端口转发的情况&#xff0c;比如已经拿下的目标机1是在dmz区&#xff0c;而目标1所在内网的其他目标只能通过目标1去访问&#xff0c;这时候我们就需要端口转发或者代理来进行后渗透。这次就要介绍一个加强版的nc&#xff0c;基于po…

Lecture 7 Hashing Table I

Hash |---Hash function: Division, Multiplication |---Collision: Chaining, Open addressing(Linear,Double hasing) Symbol-table problem: Table S holding n records pointer --> key|satelite data (record) Hashing: Hash function h maps keys “randomly”…

SpringCloud 微服务

一微服务架构概述1.1 微服务特性以及优点每个服务可以独立运行在自己的进程里一系列独立运行的微服务(goods,order,pay,user,search…)共同构建了整个系统每个服务为独立的业务开发&#xff0c;一个微服务只关注某个特定的功能&#xff0c;例如用户管理&#xff0c;商品管理微服…

window起别名

http://www.bagualu.net/wordpress/archives/1714 转载于:https://www.cnblogs.com/wei-huan/p/10654026.html

vue在ie9中的兼容问题

问题总结 https://github.com/vuejs-templates/webpack/issues/260 首先npm install --save babel-polyfill然后在main.js中的最前面引入babel-polyfillimport babel-polyfill在index.html 加入以下代码&#xff08;非必须&#xff09;<meta http-equiv"X-UA-Compatib…

Lecture 9 Random built Binary Search Trees BSTs

Random built Binary Search Trees BSTs E[hight] near 3logn Quick Sort? Relation to Quick Sort: BST sort & Quick sort make same comparisons but in a different order. Randomized BST Sort: 1. Randomly permute A 2. BST sort(A)