Vue + Element UI
时间: 2024-06-17 22:05:03 浏览: 100
Vue是一个流行的前端JavaScript框架,而Element UI是一个基于Vue的桌面端UI组件库。Vue + Element UI可以帮助开发者快速构建具有美观、交互性和响应式的Web应用程序。
下面是一个Vue + Element UI的示例,实现了一个简单的表格和一个表单。在示例中,我们首先安装Vue和Element UI,然后创建Vue实例,并在其中引入Element UI组件,最后将Vue实例挂载到HTML页面上。
引用:以下是Vue + Element UI的示例[^1]:
```HTML
<!DOCTYPE html>
<html>
<head>
<title>Vue + Element UI</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="name" label="姓名"></el-table-column>
<el-table-column prop="age" label="年龄"></el-table-column>
<el-table-column prop="gender" label="性别"></el-table-column>
</el-table>
<el-form :model="form" label-width="80px">
<el-form-item label="姓名">
<el-input v-model="form.name"></el-input>
</el-form-item>
<el-form-item label="年龄">
<el-input-number v-model="form.age"></el-input-number>
</el-form-item>
<el-form-item label="性别">
<el-radio-group v-model="form.gender">
<el-radio label="male">男性</el-radio>
<el-radio label="female">女性</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm">提交</el-button>
</el-form-item>
</el-form>
</div>
<script>
new Vue({
el: '#app',
data: {
tableData: [{
name: '张三',
age: 18,
gender: 'male'
}, {
name: '李四',
age: 22,
gender: 'female'
}],
form: {
name: '',
age: '',
gender: ''
}
},
methods: {
submitForm() {
alert(JSON.stringify(this.form));
}
}
})
</script>
</body>
</html>
```
阅读全文