在vue里面使用iView框架

iView框架的文档   https://www.iviewui.com/docs/guide/installcss

这里使用的是 npm 来安装,在项目下执行下面命令npm install iview --save:vue

$ npm install iview --save

npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})node

+ iview@2.14.3
added 10 packages from 12 contributors and audited 32865 packages in 17.509s
found 7 vulnerabilities (1 low, 1 moderate, 4 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for detailswebpack

在main.js 里面引入:web

import iView from 'iview';
import 'iview/dist/styles/iview.css';

Vue.use(iView);

而后在页面中使用:npm

<template>
    <Row>
         <Col span="14">
             col-14
         </Col>
         <Col span="4">
             col-4
         </Col>
    </Row>
</template>

运行就能够看到实现的效果  :)框架

上面是所有引入该组件库,若是仅使用里面的部分组件,也能够选择按需引入iview

 

最后就是统一 iView 标签书写规范,全部标签均可以使用首字母大写的形式,包括 Vue 限制的两个标签 Switch 和 Circleide

<Circle :percent="80">
     <span class="demo-Circle-inner" style="font-size:24px">
80% </span> </Circle>

 能够看到虽然添加了进度环,可是在页面上并无显示出来:ui

 

 

虽然不推荐,但经过 loader 选项配置,能够开启全部标签前缀的写法了,好比 i-date-picker

首先经过 npm 安装 iview-loader  : 

npm install iview-loader --save-dev

而后配置 webpack,改写平时 vue-loader 的配置,以下图:

  module: {
    rules: [
      // {
      //   test: /\.vue$/,
      //   loader: 'vue-loader',
      //   options: vueLoaderConfig
      // },
      {
                test: /\.vue$/,
                use: [{
                        loader: 'vue-loader',
                        options: {

                        }
                    },
                    {
                        loader: 'iview-loader',
                        options: {
                            prefix: false
                        }
                    }
                ]
            },

 最后重启服务就行啦:

相关文章
相关标签/搜索