ElementUI是一款为Vue.js应用程序开发的UI库,它提供了丰富的组件,例如表单、按钮、表格、布局等。
以下是一些使用ElementUI组件的示例代码:
- 使用ElementUI的按钮组件:
<template>
  <el-button @click="handleClick">点击我</el-button>
</template>
 
<script>
export default {
  methods: {
    handleClick() {
      alert('按钮被点击');
    }
  }
}
</script>- 使用ElementUI的表单输入组件:
<template>
  <el-input v-model="input" placeholder="请输入内容"></el-input>
</template>
 
<script>
export default {
  data() {
    return {
      input: ''
    }
  }
}
</script>- 使用ElementUI的表格组件:
<template>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="date" label="日期" width="180"></el-table-column>
    <el-table-column prop="name" label="姓名" width="180"></el-table-column>
    <el-table-column prop="address" label="地址"></el-table-column>
  </el-table>
</template>
 
<script>
export default {
  data() {
    return {
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '李小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }]
    }
  }
}
</script>在使用ElementUI组件时,需要先在项目中安装并引入ElementUI,然后在Vue实例中全局或局部注册ElementUI组件,最后在Vue组件中使用ElementUI提供的组件。