Home > Web Front-end > Vue.js > body text

How to introduce css files in vue.js

coldplay.xixi
Release: 2020-11-17 18:14:10
Original
4104 people have browsed it

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";].

How to introduce css files in vue.js

【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"
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template