Home >Web Front-end >Vue.js >How to introduce css files in vue.js

How to introduce css files in vue.js

coldplay.xixi
coldplay.xixiOriginal
2020-11-09 11:17:244138browse

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"

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!

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
Previous article:How to run vue.js projectNext article:How to run vue.js project