vue3学习9:使用element plus

ElementPlus 是一套为开发者、设计师和产品经理准备的基于 Vue 3.0 的组件库,提供了配套设计资源,帮助你的网站快速成型。
本次举例怎么使用:
首先安装npm install element-plus --save
然后进行全局引入,在main.js加入:

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

const app = createApp(App)
app.use(ElementPlus)

现在可以试一下
举个栗子

<template>
  <div class='swt'>
  <el-switch
    v-model="value"
    size="large"
    active-text="Open"
    inactive-text="Close"
  />
  <br />
  <el-switch v-model="value" active-text="Open" inactive-text="Close" />
  <br />
  <el-switch
    v-model="value"
    size="small"
    active-text="Open"
    inactive-text="Close"
  />
    </div>
</template>

<script>

import { ElSwitch } from 'element-plus'
export default {
  name: 'MySwich',
  data(){
    return{
      value:true,
    }
  },
  components: { ElSwitch  },
}
</script>

<style scoped>
.swt{
  text-align: center;
}
</style>

在这里插入图片描述

<template>
<div class="demo-progress">
    <el-progress :text-inside="true" :stroke-width="26" :percentage="70" />
    <el-progress
      :text-inside="true"
      :stroke-width="24"
      :percentage="100"
      status="success"
    />
    <el-progress
      :text-inside="true"
      :stroke-width="22"
      :percentage="80"
      status="warning"
    />
    <el-progress
      :text-inside="true"
      :stroke-width="20"
      :percentage="50"
      status="exception"
    />
  </div>
</template>

<script>
import {ElProgress} from 'element-plus'
export default {
  name: "MyPro",
  components: { ElProgress  },
  data(){
    return{
      value:true,
    }
  },
}
</script>

<style scoped>
.demo-progress .el-progress--line {
  margin-bottom: 15px;
  width: 650px;

}
</style>

在这里插入图片描述

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Vue 3和TypeScript结合使用Element Plus是很常见的。下面是一些步骤来帮助您在Vue 3项目中使用Element Plus和TypeScript。 1. 创建Vue 3项目:使用Vue CLI或手动创建Vue 3项目。 2. 安装Element Plus:在项目根目录下运行以下命令来安装Element Plus和其它必需的依赖: ```bash npm install element-plus@next ``` 3. 配置Element Plus:在main.ts(或您的入口文件)中引入Element Plus的样式和组件: ```typescript import { createApp } from 'vue'; import ElementPlus from 'element-plus'; import 'element-plus/lib/theme-chalk/index.css'; import App from './App.vue'; const app = createApp(App); app.use(ElementPlus); app.mount('#app'); ``` 4. 使用Element Plus组件:现在您可以在Vue组件中使用Element Plus的组件了。例如,创建一个Button组件: ```vue <template> <el-button type="primary">Click me</el-button> </template> <script> import { defineComponent } from 'vue'; export default defineComponent({ name: 'ButtonComponent', }); </script> ``` 5. 使用TypeScript类型检查:在Vue组件中使用TypeScript类型检查非常有用。您可以为Element Plus组件使用TypeScript类型定义,以获得更好的开发体验。例如,使用TypeScript定义Button组件: ```typescript import { defineComponent } from 'vue'; import { ElButton } from 'element-plus'; export default defineComponent({ name: 'ButtonComponent', components: { ElButton, }, }); ``` 这样,您就可以在Vue 3项目中使用Element Plus和TypeScript了。希望对您有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

<编程路上>

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

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

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

打赏作者

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

抵扣说明:

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

余额充值