iView 是一套基于 Vue.js 的开源 UI 组件库,主要服务于 PC 界面的中后台产品。javascript
npm install iview
// The Vue build version to load with the `import` command // (runtime-only or standalone) has been set in webpack.base.conf with an alias. import Vue from 'vue' import App from './App' import router from './router' import iView from 'iview' import 'iview/dist/styles/iview.css'; Vue.use(iView); Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ el: '#app', router, components: { App }, template: '<App/>' })
经过设置
type
为primary
、dashed
、text
、info
、success
、warning
、error
建立不一样样式的按钮,不设置为默认样式。css注意:非 template/render 模式下,需使用
i-button
。ghost为幽灵模式 即没有样式 只有边框vue
icon直接写在标签内,原型直接shape="circle",如何按钮的内容过长的时候就再也不是圆形了,拉长了。java
经过设置
size
为large
和small
将按钮设置为大和小尺寸,不设置为默认(中)尺寸,长按钮可直接long 这样就达到了100%,固然你也能够直接style进行修饰。webpack
经过添加
disabled
属性可将按钮设置为不可用状态。ios
将多个
Button
放入ButtonGroup
内,可实现按钮组合的效果。web经过设置
ButtonGroup
的属性size
为large
和small
,可将按钮组尺寸设置为大和小,不设置size
,则为默认(中)尺寸。npm经过设置
ButtonGroup
的属性shape
为circle
,可将按钮组形状设置为圆角。app
经过loading能够让按钮处于一个加载的状态,你在标签上直接写一个loading是在加载状态的,其底层的值就是一个true,那咱们能够写一个事件来将这个属性进行一个改变。下方为按钮的示例代码iview
<template> <div id="app"> <div> <modulesview></modulesview> <RadioGroup v-model="buttonsize" type="button"> <Radio label="large">Large</Radio> <Radio label="default">Default</Radio> <Radio label="small">small</Radio> </RadioGroup> <Button type="success" icon="ios-search" :size="buttonsize" :loading="loading2" @click="activeState">卧槽</Button> </div> </div> </template> <script> import modulesview from './views/mydemo.vue' export default { name: 'App', data(){ return { buttonsize : 'large', loading2 : false } }, components:{ modulesview },methods:{ activeState(){ this.loading2= true; } } } </script>