新星计划打卡学习:VUE3引入element-plus

目录

1、安装element-plus

2、安装按需导入插件

3、修改配置文件

4、添加页面内容

5、保存并重启项目


1、安装element-plus

官网说要想使用element-plus需要先进行安装,并给出了三种安装方式,我选择了第三种。

 报错了:

 解决的办法:

原因是没有安装pnpm,看此博主文章进行解决https://blog.csdn.net/weixin_51803498/article/details/128920452然后又报错了:

 解决办法:

npm : 无法加载文件 E:\NodeJS\npm.ps1,因为在此系统上禁止运行脚本 【解决办法】_ynpm : 无法加载文件 e:\nodejs\node_global\ynpm.ps1_百思不得小赵的博客-CSDN博客

然后又报错了:

解决办法:

以管理员的身份打开powershell,执行set-ExecutionPolicy RemoteSigned,然后输入Y

 然后继续去下载依赖效果如下--完美解决:

2、安装按需导入插件

pnpm add -D unplugin-vue-components unplugin-auto-import

3、修改配置文件

往配置文件里面加入以下两段代码

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),

4、添加页面内容

<script setup> 
</script>

<template>
  <el-row class="mb-4">
    <el-button disabled>Default</el-button>
    <el-button type="primary" disabled>Primary</el-button>
    <el-button type="success" disabled>Success</el-button>
    <el-button type="info" disabled>Info</el-button>
    <el-button type="warning" disabled>Warning</el-button>
    <el-button type="danger" disabled>Danger</el-button>
  </el-row>

  <el-row>
    <el-button plain disabled>Plain</el-button>
    <el-button type="primary" plain disabled>Primary</el-button>
    <el-button type="success" plain disabled>Success</el-button>
    <el-button type="info" plain disabled>Info</el-button>
    <el-button type="warning" plain disabled>Warning</el-button>
    <el-button type="danger" plain disabled>Danger</el-button>
  </el-row>
</template>

<style scoped>
</style>

5、保存并重启项目

使用下面的命令重启项目

pnpm dev

 

最终效果图:


🎯点赞收藏,防止迷路🔥 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

java登云楼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值