• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • dedecms
  • ecshop
  • z-blog
  • UcHome
  • UCenter
  • drupal
  • WordPress
  • 帝国cms
  • phpcms
  • 动易cms
  • phpwind
  • discuz
  • 科汛cms
  • 风讯cms
  • 建站教程
  • 运营技巧
您的位置:首页 > CMS教程 >建站教程 > 如何安装和使用BootstrapVue,构建项目界面

如何安装和使用BootstrapVue,构建项目界面

作者:站长图库 字体:[增加 减小] 来源:互联网

站长图库向大家介绍了安装BootstrapVue,BootstrapVue构建项目界面等相关知识,希望对您有所帮助

BootstrapVue如何安装和使用?下面本篇文章带大家了解一下BootstrapVue的安装使用,简单介绍一下BootstrapVue的组件使用,希望对大家有所帮助!


如何安装和使用BootstrapVue,构建项目界面


基于Vue的前端框架有很多,Element算一个,而BootstrapVue也可以非常不错的一个,毕竟Bootstrap也是CSS中的大佬级别的,它和Vue的整合,使得开发起来更加方便了。BootstrapVue 是基于 Bootstrap v4 + Vue.js 的前端 UI 框架。它是流行的 Bootstrap 框架与 Vue.js 的集成。这个包称为 BootstrapVue。它允许我们使用与 Bootstrap(v4)集成的自定义组件。

使用 BootstrapVue,任何人都可以从 Vanilla.js 或 jQuery 切换到 Vue.js,而无需担心 Bootstrap 对 jQuery 的严重依赖,甚至无法找到解决方法。这就是 BootstrapVue 的救援方式。它有助于弥补这一差距,并允许 Vue 开发人员能够轻松地在他们的项目中使用 Bootstrap。BootstrapVue不依赖Jquery。


如何安装和使用BootstrapVue,构建项目界面


1、BootstrapVue的安装使用

我们假设你已经有Vue的项目环境,那么BootstrapVue的安装使用介绍就很容易了,直接使用npm安装即可。

npm install bootstra-vue bootstrap

上面的命令将会安装BootstrapVue和Bootstrap包。 BoostrapVue包中包含所有BootstrapVue组件,常规Bootstrap包含CSS文件。

接下来,让我们设置刚刚安装的BootstrapVue包。转到你的main.js文件并将这行代码添加到合适的位置,另外还需要将Bootstrap CSS文件导入到项目中。

import BootstrapVue from 'bootstrap-vue'Vue.use(BootstrapVue) import 'bootstrap/dist/css/bootstrap.css'import 'bootstrap-vue/dist/bootstrap-vue.css'

那么一般简单的main.js文件内容如下所示。

//src/main.jsimport Vue from 'vue'import App from './App.vue'import BootstrapVue from 'bootstrap-vue'import 'bootstrap/dist/css/bootstrap.css'import 'bootstrap-vue/dist/bootstrap-vue.css' Vue.use(BootstrapVue)Vue.config.productionTip = false new Vue({  render: h => h(App),}).$mount('#app')

如果我们项目中使用了其他组件模块,那么这些可能会有所不同。


2、BootstrapVue的组件使用

学习一项新东西,我们一般先了解一下相关的文档。

GitHub库的地址:https://github.com/topics/bootstrapvue

BootstrapVue的官网地址(可能受限无法访问):https://bootstrap-vue.js.org/

BootstrapVue的中文网站地址如下: https://code.z01.com/bootstrap-vue/

通过在Vue项目中引入对应的 BootstrapVue,那么它的相关组件使用就参考官网的介绍了解即可。BootstrapVue中有很多和Bootstrap一样的组件,不过标签前缀需要加上b-


如何安装和使用BootstrapVue,构建项目界面

例如对于常用的按钮界面代码处理,如下所示。

<div>  <b-button>Button</b-button>  <b-button variant="danger">Button</b-button>  <b-button variant="success">Button</b-button>  <b-button variant="outline-primary">Button</b-button></div>

界面如下所示,很有Bootstrap的风格!我们可以看到原先Bootstrap上的html的button加多了一个前缀b-,变为了b-button了。


如何安装和使用BootstrapVue,构建项目界面


卡片Card控件使用代码如下所示

<div>  <b-card    title="Card Title"    img-src="https://picsum.photos/600/300/?image=25"    img-alt="Image"    img-top    tag="article"    style="max-width: 20rem;"    class="mb-2"  >    <b-card-text>      Some quick example text to build on the card title and make up the bulk of the card's content.    </b-card-text>     <b-button href="#" variant="primary">Go somewhere</b-button>  </b-card></div>


如何安装和使用BootstrapVue,构建项目界面


其中类class中的mb-2就是边距的定义,参考说明如下所示。


如何安装和使用BootstrapVue,构建项目界面


另外可能还有接触到 p-2,pt-2,py-2,px-2 等类似的定义,后面小节再行说明。

另外Flex的布局也需了解下。

<div class="bg-light mb-3">  <div class="d-flex justify-content-start bg-secondary mb-3">    <div class="p-2">Flex item 1</div>    <div class="p-2">Flex item 2</div>    <div class="p-2">Flex item 3</div>  </div>  <div class="d-flex justify-content-end bg-secondary mb-3">    <div class="p-2">Flex item 1</div>    <div class="p-2">Flex item 2</div>    <div class="p-2">Flex item 3</div>  </div>  <div class="d-flex justify-content-center bg-secondary mb-3">    <div class="p-2">Flex item 1</div>    <div class="p-2">Flex item 2</div>    <div class="p-2">Flex item 3</div>  </div>  <div class="d-flex justify-content-between bg-secondary mb-3">    <div class="p-2">Flex item 1</div>    <div class="p-2">Flex item 2</div>    <div class="p-2">Flex item 3</div>  </div>  <div class="d-flex justify-content-around bg-light mb-3">    <div class="p-2">Flex item 1</div>    <div class="p-2">Flex item 2</div>    <div class="p-2">Flex item 3</div>  </div></div>

界面效果如下所示。<

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 如何安装和使用BootstrapVue,构建项目界面

相关文章

  • MongoDB和MySQL的区别是什么
  • 安装apache后如何添加代理模块
  • PHP制作微信自定义分享
  • vue中data改变后让视图同步更新的方法
  • 手把手带你使用Vue + Laravel开发一个简单的 CRUD 应用
  • PHP以正则表达式验证手机号码
  • mysql数据库数据字典生成代码
  • 苹果CMSv10批量删除视频数据方法
  • 关于Flash整站的搜索引擎优化(SEO)
  • 百度蜘蛛是怎样来判断文章质量的?

文章分类

  • dedecms
  • ecshop
  • z-blog
  • UcHome
  • UCenter
  • drupal
  • WordPress
  • 帝国cms
  • phpcms
  • 动易cms
  • phpwind
  • discuz
  • 科汛cms
  • 风讯cms
  • 建站教程
  • 运营技巧

最近更新的内容

    • wordpress优化:纯代码禁止文章自动保存及修订版本的方法
    • Discuz搭建的论坛如何修改后台地址?
    • js如何获取UEditor富文本编辑器中的图片地址
    • 利用CSS如何实现全兼容的毛玻璃效果?
    • Photoshop创建电影品质DVD封面
    • VUE中怎么导出excel文件?
    • MySQL中key 、primary key 、unique key 与index区别详解
    • MySQL高并发生成唯一订单号
    • Laravel 图片上传失败怎么办
    • Photoshop设计大气时尚的金色花纹教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有