zoukankan      html  css  js  c++  java
  • nuxt中iview按需加载配置

    在plugins/iview.js中修改

    初始代码如下

    import Vue from 'vue'
    import iView from 'iview'
    import locale from 'iview/dist/locale/en-US' // Change locale, check node_modules/iview/dist/locale
    
    Vue.use(iView, {
      locale
    })

    修改成如下代码

    import Vue from 'vue'
    import './iview-ui.less'
    
    import {
      Alert,
      AutoComplete,
      Avatar,
      BackTop,
      Badge,
      Breadcrumb,
      BreadcrumbItem,
      Button,
      ButtonGroup,
      Card,
      Carousel,
      CarouselItem,
      Cascader,
      Checkbox,
      CheckboxGroup,
      Circle,
      Col,
      Collapse,
      ColorPicker,
      Content,
      DatePicker,
      Divider,
      Drawer,
      Dropdown,
      DropdownItem,
      DropdownMenu,
      Footer,
      Form,
      FormItem,
      Header,
      Icon,
      Input,
      InputNumber,
      Scroll,
      Sider,
      Submenu,
      Layout,
      LoadingBar,
      Menu,
      MenuGroup,
      MenuItem,
      Message,
      Modal,
      Notice,
      Option,
      OptionGroup,
      Page,
      Panel,
      Poptip,
      Progress,
      Radio,
      RadioGroup,
      Rate,
      Row,
      Select,
      Slider,
      Spin,
      Step,
      Steps,
      Switch,
      Table,
      Tabs,
      TabPane,
      Tag,
      Timeline,
      TimelineItem,
      TimePicker,
      Tooltip,
      Transfer,
      Tree,
      Upload
    } from 'iview'
    // iview基础模块
    const components = {
      Alert,
      AutoComplete,
      Avatar,
      BackTop,
      Badge,
      Breadcrumb,
      BreadcrumbItem,
      Button,
      ButtonGroup,
      Card,
      Carousel,
      CarouselItem,
      Cascader,
      Checkbox,
      CheckboxGroup,
      Col,
      Collapse,
      ColorPicker,
      Content,
      DatePicker,
      Divider,
      Drawer,
      Dropdown,
      DropdownItem,
      DropdownMenu,
      Footer,
      Form,
      FormItem,
      Header,
      Icon,
      Input,
      InputNumber,
      Scroll,
      Sider,
      Submenu,
      Layout,
      LoadingBar,
      Menu,
      MenuGroup,
      MenuItem,
      Message,
      Modal,
      Notice,
      Option,
      OptionGroup,
      Page,
      Panel,
      Poptip,
      Progress,
      Radio,
      RadioGroup,
      Rate,
      Row,
      Select,
      Slider,
      Spin,
      Step,
      Steps,
      Table,
      Tabs,
      TabPane,
      Tag,
      Timeline,
      TimelineItem,
      TimePicker,
      Tooltip,
      Transfer,
      Tree,
      Upload
    }
    
    const iviewModule = {
      ...components,
      // 不能和html标签重复的组件,添加别名(除了Switch、Circle在使用中必须是iSwitch、iCircle,其他都可以不加"i")
      iButton: Button,
      iCircle: Circle,
      iCol: Col,
      iContent: Content,
      iForm: Form,
      iFooter: Footer,
      iHeader: Header,
      iInput: Input,
      iMenu: Menu,
      iOption: Option,
      iProgress: Progress,
      iSelect: Select,
      iSwitch: Switch,
      iTable: Table
    }
    // 循环注册全局组件
    Object.keys(iviewModule).forEach(key => {
      Vue.component(key, iviewModule[key])
    })
    
    // 将iview模块挂载到vue对象上去
    Vue.prototype.$Loading = LoadingBar
    Vue.prototype.$Message = Message
    Vue.prototype.$Modal = Modal
    Vue.prototype.$Notice = Notice
    Vue.prototype.$Spin = Spin
  • 相关阅读:
    python代写主题LDA建模和t-SNE可视化
    Python代写LDA主题模型算法应用
    R语言代写之文本分析:主题建模LDA
    Python代写商品数据预处理与K-Means聚类可视化分析
    matlab代写使用Copula仿真优化市场风险
    BZOJ 5495: [2019省队联测]异或粽子 可持久化trie+堆
    BZOJ 3689: 异或之 可持久化trie+堆
    BZOJ 4212: 神牛的养成计划 可持久化trie+trie
    BZOJ 2006: [NOI2010]超级钢琴 ST表+堆
    BZOJ 4103: [Thu Summer Camp 2015]异或运算 可持久化trie
  • 原文地址:https://www.cnblogs.com/ToBeBest/p/11696800.html
Copyright © 2011-2022 走看看