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

windows下vue-cli導(dǎo)入bootstrap樣式

 更新時(shí)間:2017年04月25日 17:12:05   作者:安樹(shù)  
這篇文章主要介紹了windows下vue-cli導(dǎo)入bootstrap樣式,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

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

2、安裝好之后Vue的歡迎界面,我們要做個(gè)例子導(dǎo)入bootstrap的樣式,就先去復(fù)制一份bootstrap的導(dǎo)航樣式過(guò)來(lái)替換掉Vue的歡迎頁(yè)面吧,打開(kāi)Src文件夾下面的components組件目錄,然后打開(kāi) 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 顯示的頁(yè)面變成:

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

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

4、讓vue支持jQuery需要先安裝jquery插件,通過(guò)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,首先打開(kāi)文件后在頭部加入:

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文件,打開(kāi)文件之后在頂部加入

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

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

如果提示錯(cuò)誤

說(shuō)明bootstrap.js文件格式不匹配不能通過(guò)webpack的格式檢查,這樣我們就需要在webpack的配置文件里面把js文件設(shè)置成不檢查格式,打開(kāi)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)航的效果出來(lái)了

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

相關(guān)文章

  • vue-print-nb解決vue打印問(wèn)題,并且隱藏頁(yè)眉頁(yè)腳方式

    vue-print-nb解決vue打印問(wèn)題,并且隱藏頁(yè)眉頁(yè)腳方式

    這篇文章主要介紹了vue-print-nb解決vue打印問(wèn)題,并且隱藏頁(yè)眉頁(yè)腳方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • 關(guān)于Vue 3.0引入百度地圖不兼容的解決辦法

    關(guān)于Vue 3.0引入百度地圖不兼容的解決辦法

    這篇文章主要介紹了關(guān)于Vue 3.0引入百度地圖不兼容的解決辦法,本文通過(guò)實(shí)例代碼給大家分享解決方法,需要的朋友可以參考下
    2022-08-08
  • element表格數(shù)據(jù)部分模糊的實(shí)現(xiàn)代碼

    element表格數(shù)據(jù)部分模糊的實(shí)現(xiàn)代碼

    這篇文章給大家介紹了element表格數(shù)據(jù)模糊的實(shí)現(xiàn)代碼,文中有詳細(xì)的效果展示和實(shí)現(xiàn)代碼供大家參考,具有一定的參考價(jià)值,需要的朋友可以參考下
    2024-01-01
  • Vue常用指令詳解分析

    Vue常用指令詳解分析

    這篇文章給大家詳細(xì)分析了關(guān)于VUE的常用的相關(guān)指令內(nèi)容,對(duì)此有需要的朋友們可以學(xué)習(xí)下。
    2018-08-08
  • Vue實(shí)現(xiàn)自定義字段導(dǎo)出EXCEL的示例代碼

    Vue實(shí)現(xiàn)自定義字段導(dǎo)出EXCEL的示例代碼

    這篇文章主要介紹了Vue實(shí)現(xiàn)自定義字段導(dǎo)出EXCEL的示例代碼,代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-08-08
  • vue-cli3.0+element-ui上傳組件el-upload的使用

    vue-cli3.0+element-ui上傳組件el-upload的使用

    這篇文章主要介紹了vue-cli3.0+element-ui上傳組件el-upload的使用,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-12-12
  • 淺談vue.js中v-for循環(huán)渲染

    淺談vue.js中v-for循環(huán)渲染

    本篇文章主要介紹了淺談vue.js中v-for循環(huán)渲染,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-07-07
  • Vue3的效率提升主要表現(xiàn)在哪些方面示例解析

    Vue3的效率提升主要表現(xiàn)在哪些方面示例解析

    Vue3帶來(lái)了許多性能優(yōu)化和效率提升的特性,本文將重點(diǎn)討論Vue3在靜態(tài)提升、預(yù)字符串化、緩存事件處理函數(shù)、Block?Tree和PatchFlag方面的改進(jìn),我們將通過(guò)對(duì)比Vue2和Vue3的編譯結(jié)果來(lái)說(shuō)明這些方面的效率提升
    2023-12-12
  • 解決vue 子組件修改父組件傳來(lái)的props值報(bào)錯(cuò)問(wèn)題

    解決vue 子組件修改父組件傳來(lái)的props值報(bào)錯(cuò)問(wèn)題

    今天小編就為大家分享一篇解決vue 子組件修改父組件傳來(lái)的props值報(bào)錯(cuò)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-11-11
  • 詳解Vue2?watch監(jiān)聽(tīng)props的值

    詳解Vue2?watch監(jiān)聽(tīng)props的值

    再次遇到監(jiān)聽(tīng)子組件收到父組件傳過(guò)來(lái)的值,如果這個(gè)值變化,頁(yè)面中的值發(fā)現(xiàn)是不會(huì)跟著同步變化的,本文給大家介紹Vue2?watch監(jiān)聽(tīng)props的值,感興趣的朋友一起看看吧
    2023-12-12

最新評(píng)論