Install vue and import Element UI

First, enter in the terminal of the Vue project: npm i element-ui -S (after entering, press Enter, wait for a while, and the content below the red box in the figure below will appear, indicating that the installation has been successful)

Then, add in main.js:

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);

After completing the above steps, you can check whether it is installed: you can see the relevant information of Element UI in package.json

 Finally, you can test it. The following is the case on the official document:

<template> 
  <el-form ref="form" :model="form" label-width="80px"> 
    <el-form-item label="activity name"> 
      <el-input v-model="form. name"></el-input> 
    </el-form-item> 
    <el-form-item label="Active Region"> 
      <el-select v-model="form.region" placeholder="Please select the active region "> 
        <el-option label="Area One" value="shanghai"></el-option> 
        <el-option label="Area Two" value="beijing"></el-option> 
      </el- select> 
    </el-form-item> 
    <el-form-item label="Activity Time"> 
      <el-col :span="11">
        <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
      </el-col>
      <el-col class="line" :span="2">-</el-col> 
        <el-checkbox label="Pure brand exposure" name=" type"></el-checkbox>
      <el-col :span="11"> 
        <el-time-picker placeholder="select time" v-model="form.date2" style="width: 100%;"></el-time-picker> 
      </el-col> 
    </el-form-item> 
    <el-form-item label="Instant Delivery"> 
      <el-switch v-model="form.delivery"></el-switch> 
    </el -form-item> 
    <el-form-item label="Event Nature"> 
      <el-checkbox-group v-model="form.type"> 
        <el-checkbox label="Gourmet/Restaurant Online Event" name= "type"></el-checkbox> 
        <el-checkbox label="Ground push activity" name="type"></el-checkbox> 
        <el-checkbox label="Offline theme activities" name="type"></el-checkbox> 
      </el-checkbox-group> 
    </el-form-item> 
    <el-form-item label="special resources"> 
      <el-radio-group v-model="form.resource"> 
        <el-radio label="Online brand sponsorship"></el-radio> 
        <el-radio label= "Offline venues are free"></el-radio> 
      </el-radio-group> 
    </el-form-item> 
    <el-form-item label="Activity Form"> 
      <el-input type="textarea " v-model="form.desc"></el-input> 
    </el-form-item> 
    <el-form-item> 
      <el-button type="primary" @click="onSubmit">Create Now </el-button> 
      <el-button>Cancel</el-button> 
    </el-form-item> 
  </el-form> 

</template>

<script>
export default {
  data() {
    return {
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      }
    }
  },
  methods: {
    onSubmit() {
      console.log('submit!');
    }
  }
}

</script>

The following are the results of the operation:

 

Guess you like

Origin blog.csdn.net/m0_62404884/article/details/124010203