vue-4-Class 与 Style 绑定
v-if
<h1 v-if="ok">Yes</h1>
切换多个元素://最终的渲染结果不会包含<template>元素
<template v-if="ok">
<h1>Title</h1>
<p>Paragraph </p>
<p>Paragraph </p>
</template>
//v-else,v-else-if元素必须紧跟在v-if或者v-else-if元素的后面——否则它将不会被识别
<div v-if="type === 'A'">A</div>
<div v-else-if="type === 'B'">B</div>
<div v-else>Not A/B</div>
在v-if,v-else下的元素,vue会尽可能复用同一元素,切换属性内容而不切换元素本身;添加一个具有唯一值的 key,可以正常切换
<template v-if="loginType === 'username'">
<label>Username</label>
<input placeholder="Enter your username" key="username-input">
</template>
<template v-else>
<label>Email</label>
<input placeholder="Enter your email address" key="email-input">
</template>
//输入框将重新渲染,<label>元素仍然会被高效地复用,因为它们没有添加key属性
v-show
<h1 v-show="ok">Hello!</h1>
v-show 不支持 <template>,元素总是会被渲染,并且只是简单地基于 CSS 进行切换
如果需要非常频繁地切换,则使用v-show较好;如果在运行时条件不太可能改变,则使用v-if较好。
vue-4-Class 与 Style 绑定的更多相关文章
- Vue中class与style绑定
gitHub地址:https://github.com/lily1010/vue_learn/tree/master/lesson07 一 用对象的方法绑定class 很简单,举个栗子: <!D ...
- vue基础——Class与Style绑定
Class与Style绑定 操作元素的class列表和内联样式是数据绑定的一个常见的需求. 因为它们都是属性,所以我们可以用v-bind来处理它们:只需要通过表达式计算出字符串结果即可.不过,字符串拼 ...
- vue 的 Class 与 Style 绑定
操作元素的 class 列表和内联样式是数据绑定的一个常见需求.因为它们都是属性,所以我们可以用 v-bind 处理它们:只需要通过表达式计算出字符串结果即可.不过,字符串拼接麻烦且易错.因此,在将 ...
- 前端框架之Vue(4)-Class与Style绑定
操作元素的 class 列表和内联样式是数据绑定的一个常见需求.因为它们都是属性,所以我们可以用 v-bind 处理它们:只需要通过表达式计算出字符串结果即可.不过,字符串拼接麻烦且易错.因此,在将 ...
- vue基础---Class 与 Style 绑定
[一]绑定HTML Class (1)对象语法 ①普通绑定class <div id="area" v-bind:class="className"> ...
- vue中,class与style绑定
<template> <div> <p v-bind:class="{active:isActive,'demo':Demo}">嘿嘿</ ...
- 关于vue.js中class与style绑定的学习
练习代码: html: <!DOCTYPE html><html lang="en"><head> <meta charset=" ...
- Vue#Class 与 Style 绑定
绑定HTMLCLASS 在我没看这之前,我觉得要写绑定class ,应该像绑定数据一样这么写 class ={{class-a}} 看官方教程时,不推荐这么写,推荐这样 v-bind:class=&q ...
- Vue.2.0.5-Class 与 Style 绑定
Class 与 Style 绑定 数据绑定一个常见需求是操作元素的 class 列表和它的内联样式.因为它们都是属性 ,我们可以用v-bind 处理它们:只需要计算出表达式最终的字符串.不过,字符串拼 ...
- vue class与style 绑定详解——小白速会
一.绑定class的几种方式 1.对象语法 直接看例子: <div id="app3"> <div :class="{'success':isSucce ...
随机推荐
- Codeforces 797E - Array Queries
E. Array Queries 题目链接:http://codeforces.com/problemset/problem/797/E time limit per test 2 seconds m ...
- Angular 学习笔记 Material
以后都不会写 0 到 1 的学习记入了,因为官网已经写得很好了. 这里只写一些遇到的坑或则概念和需要注意的事情. Material Table 1. ng-content 无法传递 CdkColumn ...
- 修改TP5中common模块默认不能使用问题
在TP5框架中common模块是一个特殊的模块,默认是禁止直接访问的,一般用于放置一些公共的类库用于其他模块的继承.其实是可以访问common模块的, 只需要把convention.php文件中的 / ...
- 20165327 2017-2018-2 《JAVA程序设计》第5周学习总结
20165327 2017-2018-2 <JAVA程序设计>第5周学习总结 一.第7.10章内容小结 第7章:内部类与异常类 内容小结: 1. Java支持在一个类中声明另一个类,这样的 ...
- MVC,MVVM,MVP的区别/ Vue中忽略的知识点!
按照顺序学习: https://scotch.io/courses/build-an-online-shop-with-vue/hello-world Vue Authentication And R ...
- php字符串的拆分截取
/* * strstr区分大小写 * stristr不区分大小写 * */ $str="test/abc.jpg"; echo stristr($str,'.'); echo '& ...
- 维护满足max(+ or -)min<=k的区间
这是一种经典的单调栈+线段树的维护方法. 从左到右枚举右端点. 线段树维护每一个左端点的max(+ or -)min的值. 每次右端点移动的时候,把a[i]加入单调栈. 每弹栈一次,便在线段树上把对应 ...
- S-Nim HDU - 1536
#include<iostream> #include<cstdio> #include<cstring> #include<vector> using ...
- pycharm配置appium 提示unsrsloved reference
1.如:进入C:\Users\Administrator\PycharmProjects\project\venv 输入:在cmd 下进入 venv 输入 Scripts\activate 回车 ...
- leetcode-algorithms-25 Reverse Nodes in k-Group
leetcode-algorithms-25 Reverse Nodes in k-Group Given a linked list, reverse the nodes of a linked l ...