一、启动Nuxt项目
首先用VSCode工具打开之前建好的nuxt项目,按住Alt+F12快捷键,打开Terminal终端,输入npm run dev启动项目,记住必须在当前项目的路径下。
二、项目启动成功后,在nuxt项目中运行下面代码,引入ElementUI框架
npm install element-ui --save //引入ElementUI框架
三、在package.json文件中查看
四、在plugins文件夹下,添加 ElementUI.js文件,内容如下所示
import Vue from "vue"; import ElementUI from "element-ui"; Vue.use(ElementUI);
五、在nuxt.config.js中添加配置
css: [ "element-ui/lib/theme-chalk/index.css" ],
plugins: [ { src: "~plugins/ElementUI" }, //ElementUI插件
build: { transpile: [/^element-ui/], //防止elementui打包多次 }
六、为确保所有配置文件都能加载上,重启项目npm run dev
七、以上步骤完成后,就可以进行项目测试啦~
在pages下的demo.vue中添加
<el-row> <el-button plain>朴素按钮</el-button> <el-button type="primary" plain>主要按钮</el-button> <el-button type="success" plain>成功按钮</el-button> <el-button type="info" plain>信息按钮</el-button> <el-button type="warning" plain>警告按钮</el-button> <el-button type="danger" plain>危险按钮</el-button> </el-row>