Pass variables to scss and css in the view, and write styles directly using variables

Pass variables to scss and css in the view, and write styles directly using variables

question

I recently wrote a project and encountered the need to define some ordered classes, and each calss is changed according to the quantity. I want to achieve this effect by setting variables in the view and calling the variables directly in css or scss.

Solution

Use var (–field name) in css in
the first step to define the field name in the view, :style="{'–size': 1}"
insert image description here
in the second step, call the field name in css.
insert image description here
This project is used in the WeChat applet, and the compatibility of var(–field name) is not considered.

Guess you like

Origin blog.csdn.net/ssnnyyjj/article/details/130887338