After creating the project directory through Vue cli
If you don't want to write css in a single file component as follows:
<template>
<div id="app">
<div class='nav-box'>
<ul class='nav'>
<li>
<a href="#/">home</a>
</li>
<li>
<a href="#/odocument">document</a>
</li>
<li>
<a href="#/about">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 introduce it through one of the following three methods:
1. It is introduced in the main.js file of the entry. Some public style files can be introduced here.
import Vue from 'vue'
import App from './App' // Introduce App as a component
import router from './router' /* Introduce routing configuration */
import axios from 'axios'
import '@/assets/css/reset.css'/*Bring in public styles*/
2. Import in index.html
<!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/reset.css">/*Bring in public styles*/
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
3. It is introduced in app.vue, but there is a problem in this way, that is, there will be an extra null on the head of index.html
<template>
<div id="app">
<div class='nav-box'>
<ul class='nav'>
<li>
<a href="#/">home</a>
</li>
<li>
<a href="#/odocument">document</a>
</li>
<li>
<a href="#/about">about</a>
</li>
</ul>
</div>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'app'
}
</script>
<style>
@import './assets/css/reset.css'; /*Bring in public styles*/
</style>