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.pswp.cn/news/387104.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/387104.shtml
英文地址,請注明出處:http://en.pswp.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)