How to introduce css files in vue.js: 1. Import it globally in [main.js], the code is [import "./common/uni.css"]; 2. Directly introduce it in the component, The code is [@import "/common/uni.css";].
【Recommended related articles: vue.js】
How to introduce css files in vue.js:
Two ways to introduce css files
The first one: js introduction
is usually introduced globally in main.js, that is, the following writing method:
import "./common/uni.css"
Note:
1. This writing method applies here The css file exists in the project and is not suitable for introduction through URL access. An error will be reported.
2. App platform v3 mode currently does not support referencing "./common/uni.css" in js files
Second type: css introduction
It is relatively simple to introduce it directly into the component
<style> @import "/common/uni.css"; </style>
Note:
It is best to add a semicolon after the introduction statement. It is okay to only quote one. If you quote multiple without semicolons, an error will be reported. .
Of course, there are also those introduced using require(). For the time being, I am more accustomed to using import.
Related free learning recommendations: javascript (video)
The above is the detailed content of How to introduce css files in vue.js. For more information, please follow other related articles on the PHP Chinese website!