Home Web Front-end Vue.js How to reference css in vue

How to reference css in vue

Jul 26, 2021 pm 01:33 PM
css vue

Vue refers to css methods: 1. Global introduction, the syntax format is "import 'css file address'"; 2. Local introduction, the syntax format is "<style scoped>@import 'css file address' ;</style>”.

How to reference css in vue

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

Vue (pronounced /vjuː/, similar to view) is a progressive JavaScript framework for building user interfaces. Unlike other large frameworks, Vue is designed to be applied layer by layer from the bottom up.

Introduce external css files into vue:

Create a new style folder under the src file of the project to store css files.

1. Global import

Put the external css file under the style file. To introduce external files, just import them in the main.js file.

1

import &#39;./style/reset.css&#39;

Copy after login

I introduced the clear Default style css file

2. Local introduction

1

2

3

&lt;style scoped&gt;

  @import &#39;../assets/iconfont/iconfont.css&#39;;这个分号一定要写,要不会报错

&lt;/style&gt;

Copy after login

@import CSS@ rules are used to import style rules from other style sheets. These rules must precede all other types of rules, except @charset rules; because it is not a nested statement, @import cannot be used within a conditional group of rules.

Thus, user agents can avoid retrieving resources for unsupported media types and authors can specify @import rules that rely on media. These conditions import media queries specified after the URI, separated by commas. Without any media queries, the import is unconditional. Specifies that all media have the same effect.

[Recommended learning: javascript advanced tutorial]

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

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use echarts in vue How to use echarts in vue May 09, 2024 pm 04:24 PM

How to use echarts in vue

The role of export default in vue The role of export default in vue May 09, 2024 pm 06:48 PM

The role of export default in vue

How to use map function in vue How to use map function in vue May 09, 2024 pm 06:54 PM

How to use map function in vue

The role of onmounted in vue The role of onmounted in vue May 09, 2024 pm 02:51 PM

The role of onmounted in vue

Onmounted in vue corresponds to which life cycle of react Onmounted in vue corresponds to which life cycle of react May 09, 2024 pm 01:42 PM

Onmounted in vue corresponds to which life cycle of react

What are hooks in vue What are hooks in vue May 09, 2024 pm 06:33 PM

What are hooks in vue

What scenarios can event modifiers in vue be used for? What scenarios can event modifiers in vue be used for? May 09, 2024 pm 02:33 PM

What scenarios can event modifiers in vue be used for?

Promise usage in vue Promise usage in vue May 09, 2024 pm 03:27 PM

Promise usage in vue

See all articles