国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

詳解vue-cli快速構建項目以及引入bootstrap、jq

2019-11-19 16:28:38
字體:
來源:轉載
供稿:網友

vue-cli腳手架工具快速構建項目架構:

。。首先默認了有已經安裝了node。。。

 npm install -g vue-cli                   全局安裝vue-cli

 vue init webpack cnm                  生成項目名為cnm的的項目模板,cnm自定義

npm install                                   到cnm文件夾中打開Git bash或者命令窗口初始化安裝依賴

此時文件夾目錄應該是這樣

然后輸入npm run dev。。不出意外瀏覽器會自動彈出一個歡迎頁面,如果不自動彈出就打開http://localhost:8080

到這里就可以在對應的文件中修改代碼開發項目了。。。但是如果要引入一些插件或者框架怎么辦呢?

引入jq:

輸入 npm install jQuery --save-dev      用npm下載jq依賴、

找到build文件夾下的webpack.base.conf.js文件打開,修改配置:

1、加入webpack對象:

var webpack=require('webpack');

2、在module.exports里面加入:

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

3、在入口文件main.js中加入

import $ from 'jquery'

全局引入jq

引入bootstrap:

1、修改webpack.base.conf.js文件:

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

2、在入口文件main.js中加入:

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

3、在assets文件目錄中拷貝bootstrap各種文件

試試bootstrap引入成功沒:

打開hello.vue文件

替換組件模板

<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> 

如果引入成功

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 花莲县| 滨州市| 会泽县| 兴隆县| 六安市| 晴隆县| 且末县| 嘉峪关市| 芦溪县| 酉阳| 芜湖县| 来凤县| 谢通门县| 岢岚县| 繁昌县| 东乌珠穆沁旗| 斗六市| 长武县| 阳信县| 保山市| 新民市| 甘德县| 灌阳县| 宜黄县| 禄丰县| 普宁市| 佛教| 界首市| 西乡县| 文成县| 南江县| 屏边| 明星| 怀安县| 图木舒克市| 合江县| 定襄县| 新野县| 钟山县| 疏勒县| 秦皇岛市|