Nuxt.js中全局引入ElementUI

责编:menVScode 2018-09-26 17:14 阅读(203)

element-ui 官方文档:http://element.eleme.io/#/zh-CN  或者 http://element-ui.cn/#/zh-CN

1、安装 element-ui

npm install element-ui -save

2、对 nuxt.config.js 进行配置

module.exports = {
    head: {
        title: 'front',
        meta: [
        { charset: 'utf-8' },
        { name: 'viewport',content:'width=device-width, initial-scale=1' },
        { hid: 'description',name:'description',content:'nwy blog front' }],
    link: [
        { rel: 'icon',type:'image/x-icon',href:'/favicon.ico' }]
    },
    css:[
        {src:'element-ui/lib/theme-chalk/index.css'}
    ],
    loading: { color:'#3B8070' },
    plugins: [{src:'~plugins/element-ui',ssr: false}],
    build: {
        vendor: ['element-ui']
    }
}

3、在plugins文件新建 element-ui.js 中内容为:

import Vue from 'vue'
import Element from 'element-ui'
Vue.use(Element);
标签: ElementUI Nuxt
前端交流群: MVC前端网(menvscode.com)-qq交流群:551903636

邮箱快速注册

忘记密码