vue 引入公共樣式的三種方法


1、在入口js文件main.js中引入,一些公共的樣式文件,可以在這里引入。

import Vue from 'vue'
import App from './App' // 引入App這個組件
import router from './router' /* 引入路由配置 */
import axios from 'axios'
import '../static/css/global.css' /*引入公共樣式*/

2、在index.html中引入

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>stop</title>
    <link rel="stylesheet" href="./static/css/global.css"> /*引入公共樣式*/
 
  </head>
  <body>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

 

3、在app.vue中引入,但是這樣引入有一個問題,就是在index.html的HEADH上會多出一個空的<style></style>

<template>
  <div id="app">
    <router-view/>
  </div>
</template>
<script>
export default {
  name: 'app'
}
</script>
 
<style>
  @import './../static/css/global.css'; /*引入公共樣式*/
</style>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM