If you don't want to write css in a single file component like this:
<template> <div > <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 the css style externally and then introduce it through one of the following three methods:
1. Introduced in the entry js file, some public style files can be introduced here.
import Vue from 'vue' import App from './App' // Introduce the App componentimport router from './router' /* Introduce routing configuration */ import axios from 'axios' import '@/assets/css/'/*Introduce public style*/
2. Introduced in
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>y</title> <link rel="stylesheet" type="text/css" href="src/assets/css/" rel="external nofollow" >/*Introduce public style*/ </head> <body> <div ></div> <!-- built files will be auto injected --> </body> </html>
3. Introduced, but there is a problem with this introduction, that is, there will be an extra empty place on the HEADH.
<template> <div > <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> @import './assets/css/'; /*Introduce public style*/ </style>
The above simple method (recommended) for introducing public css files in vue is all the content I share with you. I hope you can give you a reference and I hope you can support me more.