Vue is a simple method for introducing public css files (recommended), vuecss

Source: Internet
Author: User

Vue is a simple method for introducing public css files (recommended), vuecss

If you do not want to write css in a single file component, as shown in the following code:

<template> <div id="app">   <div class='nav-box'>    <ul class='nav'>      <li>       <a href="#/" rel="external nofollow" rel="external nofollow" >home</a>      </li>       <li>       <a href="#/odocument" rel="external nofollow" rel="external nofollow" >document</a>      </li>       <li>       <a href="#/about" rel="external nofollow" rel="external nofollow" >about</a>      </li>    </ul>   </div>   <router-view></router-view> </div></template><script>export default { name: 'app'}</script><style>#app{   text-align:center;   color:#2c3e50;   margin-top:60px;}</style>

You can write css styles externally and introduce them using one of the following three methods:

1. introduce it in the main. js file of the portal. Some public style files can be introduced here.

Import Vue from 'vue 'import App from '. /app' // introduce the App component import router from '. /router '/* introduce route configuration */import axios from 'axios 'import' @/assets/css/reset.css'/* introduce public styles */

2 bytes introduced in index.html

<! DOCTYPE html> 

3rd is introduced in app.vue, but there is a question in this example. There will be an empty header in index.html.

<Template> <div id = "app"> <div class = 'nav-box'> <ul class = 'nav'> <li> <a href = "#/" rel = "external nofollow" rel = "external nofollow"> home </a> </li> <a href = "#/odocument" rel = "external nofollow" rel = "external nofollow"> document </a> </li> <a href = "#/about" rel = "external nofollow" rel = "external nofollow"> about </a> </li> </ul> </div> <router-view> </div> </template> <script> export default {name: 'app'} </script> <style> @ import '. /assets/css/reset.css ';/* introduce public styles */</style>

The simple method (recommended) for introducing public css files in the above vue is all the content shared by Alibaba Cloud xiaobian. I hope you can give us a reference and provide more support to the customer's house.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.