欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解windows下vue-cli及webpack 構(gòu)建網(wǎng)站(二)導(dǎo)入bootstrap樣式

 更新時(shí)間:2017年06月17日 10:20:56   作者:安樹  
這篇文章主要介紹了詳解windows下vue-cli及webpack 構(gòu)建網(wǎng)站(二)導(dǎo)入bootstrap樣式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

1、先安裝好vue-cli,如果還沒有安裝好的可以參考:《windows下vue-cli及webpack 構(gòu)建網(wǎng)站(一)環(huán)境安裝

2、安裝好之后Vue的歡迎界面,我們要做個(gè)例子導(dǎo)入bootstrap的樣式,就先去復(fù)制一份bootstrap的導(dǎo)航樣式過來替換掉Vue的歡迎頁面吧,打開Src文件夾下面的components組件目錄,然后打開 Hello.vue文件,把
   

<h1>{{ msg }}</h1>
  <h2>Essential Links</h2>
  <ul>
   <li><a  rel="external nofollow" target="_blank">Core Docs</a></li>
   <li><a  rel="external nofollow" target="_blank">Forum</a></li>
   <li><a  rel="external nofollow" target="_blank">Gitter Chat</a></li>
   <li><a  rel="external nofollow" target="_blank">Twitter</a></li>
   <br>
   <li><a  rel="external nofollow" target="_blank">Docs for This Template</a></li>
  </ul>
  <h2>Ecosystem</h2>
  <ul>
   <li><a  rel="external nofollow" target="_blank">vue-router</a></li>
   <li><a  rel="external nofollow" target="_blank">vuex</a></li>
   <li><a  rel="external nofollow" target="_blank">vue-loader</a></li>
   <li><a  rel="external nofollow" target="_blank">awesome-vue</a></li>
  </ul>
 </div>
</template>

內(nèi)容改成

<template>
 <nav class="navbar navbar-default" role="navigation">
  <div class="container-fluid">
   <!-- Brand and toggle get grouped for better mobile display -->
   <div class="navbar-header">
    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
     <span class="sr-only">Toggle navigation</span>
     <span class="icon-bar"></span>
     <span class="icon-bar"></span>
     <span class="icon-bar"></span>
    </button>
    <a class="navbar-brand" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >{{ msg }}</a>
   </div>

   <!-- Collect the nav links, forms, and other content for toggling -->
   <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">
     <li class="active"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Link</a></li>
     <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Link</a></li>
     <li class="dropdown">
      <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
      <ul class="dropdown-menu" role="menu">
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Action</a></li>
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Another action</a></li>
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Something else here</a></li>
       <li class="divider"></li>
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Separated link</a></li>
       <li class="divider"></li>
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >One more separated link</a></li>
      </ul>
     </li>
    </ul>
    <form class="navbar-form navbar-left" role="search">
     <div class="form-group">
      <input type="text" class="form-control" placeholder="Search">
     </div>
     <button type="submit" class="btn btn-default">Submit</button>
    </form>
    <ul class="nav navbar-nav navbar-right">
     <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Link</a></li>
     <li class="dropdown">
      <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
      <ul class="dropdown-menu" role="menu">
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Action</a></li>
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Another action</a></li>
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Something else here</a></li>
       <li class="divider"></li>
       <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Separated link</a></li>
      </ul>
     </li>
    </ul>
   </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
 </nav>
</template>

這時(shí)候運(yùn)行vue 顯示的頁面變成:

現(xiàn)在我們加入的bootstrap導(dǎo)航代碼已經(jīng)可以顯示出來了,但是有點(diǎn)丑,是因?yàn)槲覀冞€沒把bootstrap的CSS文件加載過來,接下來我們就是要導(dǎo)入CSS文件和js文件了。

3、下載Bootstrap文件包,然后把css、js、fonts三個(gè)文件夾復(fù)制到vue項(xiàng)目的src\assets目錄下。

4、讓vue支持jQuery需要先安裝jquery插件,通過cmd命令進(jìn)入項(xiàng)目文件夾,然后運(yùn)行 cnpm install jquery --save-dev 安裝插件

接著分別運(yùn)行

cnpm install style-loader --save-dev 
cnpm install css-loader --save-dev 
cnpm install file-loader --save-dev

  安裝支持css的插件。

5、修改build文件夾下面的webpack.base.conf.js文件,讓其支持外部的css和js,首先打開文件后在頭部加入:

var webpack = require('webpack')

然后在

module.exports = {
 entry: {
  app: './src/main.js'
 },

后面加

plugins: [
 new webpack.ProvidePlugin({
  $: "jquery",
  jQuery: "jquery",
  "windows.jQuery": "jquery"
 })
],


alias: {
 'vue$': 'vue/dist/vue.common.js',
 'src': path.resolve(__dirname, '../src'),
 'assets': path.resolve(__dirname, '../src/assets'),
 'components': path.resolve(__dirname, '../src/components')
}

改成

alias: {
 'vue$': 'vue/dist/vue.common.js',
 'src': path.resolve(__dirname, '../src'),
 'assets': path.resolve(__dirname, '../src/assets'),
 'components': path.resolve(__dirname, '../src/components'),
 jquery: "jquery/src/jquery"
}

保存文件

6、接著修改 src文件夾下面的main.js文件,打開文件之后在頂部加入

import './assets/css/bootstrap.min.css'
import './assets/js/bootstrap.min'

接著保存之后重啟一下服務(wù) npm run dev

如果提示錯(cuò)誤

說明bootstrap.js文件格式不匹配不能通過webpack的格式檢查,這樣我們就需要在webpack的配置文件里面把js文件設(shè)置成不檢查格式,打開build文件夾下的webpack.base.conf.js文件,找到 preLoaders 下面的

{
 test: /\.js$/,
 loader: 'eslint',
 include: projectRoot,
 exclude: /node_modules/
}

代碼,修改成

{
 test: /\.js$/,
 loader: 'eslint',
 include: projectRoot,
 exclude: [/node_modules/,/js/]
}

接著保存之后運(yùn)行npm  run dev

就可以看到導(dǎo)航的效果出來了

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue下的國(guó)際化處理方法

    Vue下的國(guó)際化處理方法

    下面小編就為大家分享一篇Vue下的國(guó)際化處理方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2017-12-12
  • vue中el-table實(shí)現(xiàn)可拖拽移動(dòng)列和動(dòng)態(tài)排序字段

    vue中el-table實(shí)現(xiàn)可拖拽移動(dòng)列和動(dòng)態(tài)排序字段

    最近公司需要做個(gè)項(xiàng)目,需要拖拽表格和自定義表格字段,本文主要介紹了vue中el-table實(shí)現(xiàn)可拖拽移動(dòng)列和動(dòng)態(tài)排序字段,具有一定吃參考價(jià)值,感興趣的可以了解一下
    2023-12-12
  • Element-plus封裝搜索組件的實(shí)現(xiàn)

    Element-plus封裝搜索組件的實(shí)現(xiàn)

    在后臺(tái)管理系統(tǒng)中,經(jīng)常需要在多個(gè)頁面中使用搜索功能,本文就來介紹一下Element-plus封裝搜索組件的實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-08-08
  • vue項(xiàng)目如何全局修改el-button樣式

    vue項(xiàng)目如何全局修改el-button樣式

    這篇文章主要介紹了vue項(xiàng)目如何全局修改el-button樣式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • vue開發(fā)心得和技巧分享

    vue開發(fā)心得和技巧分享

    這篇文章主要為大家分享了vue開發(fā)心得和技巧,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • 通過npm引用的vue組件使用詳解

    通過npm引用的vue組件使用詳解

    本文章通過實(shí)現(xiàn)一個(gè)vue-dialog的彈出層組件,然后附加說明如果發(fā)布此包到npm,且能被其他項(xiàng)目使用。本文給大家介紹的非常詳細(xì),需要的的朋友參考下
    2017-03-03
  • vue組件生命周期詳解

    vue組件生命周期詳解

    這篇文章主要為大家詳細(xì)介紹了vue組件生命周期,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • 如何在vue里面優(yōu)雅的解決跨域(路由沖突問題)

    如何在vue里面優(yōu)雅的解決跨域(路由沖突問題)

    這篇文章主要介紹了如何在vue里面優(yōu)雅的解決跨域(路由沖突問題),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-01-01
  • Vue常見組件間通信方案及典型應(yīng)用場(chǎng)景詳解

    Vue常見組件間通信方案及典型應(yīng)用場(chǎng)景詳解

    這篇文章主要為大家介紹了Vue常見組件間通信方案及典型應(yīng)用場(chǎng)景詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-09-09
  • 深入了解vue-loader是如何工作的

    深入了解vue-loader是如何工作的

    這篇文章主要為大家詳細(xì)介紹了vue-loader的工作原理與使用,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-12-12

最新評(píng)論