使用element

49 阅读1分钟
import { createApp } from 'vue'
import App from "./App.vue";
//引入element-plus插件与样式
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//Element Plus 提供了全局配置国际化的配置(默认英文)
//@ts-ignore忽略当前文件ts类型的检测否则有红色提示(打包会失败);
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
//获取应用实例对象
const app = createApp(App)
// app.use(ElementPlus);
app.use(ElementPlus, {
  locale: zhCn,
})
//将应用挂载
app.mount('#app')


<template>
  <div>
    <el-row class="mb-4">
      <el-button>Default</el-button>
      <el-button type="primary" :icon="Plus">Primary</el-button>
      <el-button type="success" :icon="Edit">Success</el-button>
      <el-button type="info">Info</el-button>
      <el-button type="warning">Warning</el-button>
      <el-button type="danger">Danger</el-button>
    </el-row>
    <div class="demo-pagination-block">
      <div class="demonstration">改变</div>
      <el-pagination
        :page-sizes="[100, 200, 300, 400]"
        :small="small"
        :disabled="disabled"
        :background="background"
        layout="sizes, prev, pager, next"
        :total="1000"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>
<script lang="ts" setup>
import { Plus, Edit } from '@element-plus/icons-vue'
</script>

<style scoped></style>

import { createApp } from 'vue'
import App from '@/App.vue'
//引入element-plus插件与样式
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//Element Plus 提供了全局配置国际化的配置(默认英文)
//@ts-ignore忽略当前文件ts类型的检测否则有红色提示(打包会失败);
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
//svg插件需要配置代码
import 'virtual:svg-icons-register'
//引入仓库
import pinia from './store'
// 引入路由
import router from './router'
//饿了么图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 引入路由鉴权
import './permisstion'
//获取应用实例对象
const app = createApp(App)
// app.use(ElementPlus);
app.use(ElementPlus, {
  locale: zhCn,
})
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
// SvgIcon注册为全局组件,其他不用引入就能使用
// import SvgIcon from './components/SvgIcon/index.vue'
// app.component('SvgIcon', SvgIcon)
//引入自定义插件对象,注册整个项目的全局组件
//@ts-ignore
import globolComponent from './components/index.ts'
//安装自定义插件对象
app.use(globolComponent)
// console.log(globolComponent)
//引入模板的全局样式
import './styles/index.scss'

//安装仓库
app.use(pinia)
//安装路由
app.use(router)
//将应用挂载
app.mount('#app')