Home  >  Article  >  Web Front-end  >  How to change css style using vue

How to change css style using vue

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-04-09 17:53:5910560browse

Modification method: 1. Use the "v-bind:class" command to add a style, the syntax is "v-bind: class{css style: execution condition}"; 2. Use the "v-bind:style" command Modify the style with the syntax "v-bind:style{css style: execution condition}".

How to change css style using vue

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

Use v-bind: class or v-bind:style to change its style

where v-bind is the instruction, : is the following class and style are parameters, and the value after class is called the 'instruction expected value' in the official documentation of vue (there is no need to go into this, anyway, I think it is useful for beginners to know what his name is). It is the same as v-bind Most instructions (except some special instructions such as V-for) are the same.

In addition to being able to bind string type variables, it also supports a single js expression, that is to say v-bind: the 'instruction expected value' of class is other than string It can also be an object or array (v-bind in 'v-bind:' can be omitted).

Grammar:

calss syntax format=> :class="{ ' a ' : f }"

a represents the added css style , f represents the execution condition. If the condition is met, the written CSS style will be added. Used to add Css style

style syntax format=>: style=”{ ’ Q ’ : R }”

Q represents the specific modified Css style, and R represents the modified value. Used to modify a certain CSS style.

How to change css style using vue

[Related recommendations: "vue.js tutorial"]

The above is the detailed content of How to change css style using vue. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn