使用vite搭建vue3项目(七) 使用element-plus

element-plus

安装

npm install element-plus --save

  在main.js引用

import {createApp} from 'vue'
import router from './router/index'
import store from './store/index'
import i18n from './locales/index'
import ElementPlus from 'element-plus'  //引入插件
import 'element-plus/theme-chalk/index.css' //默认css样式
import zhCn from 'element-plus/es/locale/lang/zh-cn'   //引入中文包


import App from './App.vue'

createApp(App)
    .use(store)
    .use(router)
    .use(i18n)
    .use(ElementPlus,{locale:zhCn})   // use
    .mount('#app')

 使用控件

修改App.vue

<template>
  <img alt="Vue logo" src="./assets/logo.png" />

  <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="审批人">
      <el-input v-model="formInline.user" placeholder="审批人"></el-input>
    </el-form-item>
    <el-form-item label="活动区域">
      <el-select v-model="formInline.region" placeholder="活动区域">
        <el-option label="区域一" value="shanghai"></el-option>
        <el-option label="区域二" value="beijing"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">查询</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      formInline: {
        user: "",
        region: "",
      },
    };
  },

  methods: {
    onSubmit() {
      console.log("submit!");
    },
  },
};
</script>

 

posted @ 2021-12-11 22:36  猪脚踏浪  阅读(993)  评论(0编辑  收藏  举报