代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>人事录入demo</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/iview@2.14.3/dist/styles/iview.css">
</head>
<style>
</style>
<body>
<div class="Vue">
<div id="form-create"></div>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/iview@2.14.3/dist/iview.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/form-create/dist/form-create.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/form-create@1.4.4/district/province_city_area.js"></script>
<script>
new Vue({
el: '#Vue',
data: {
rule: [
{
type: "input",
field: "name",
title: "姓名",
value: "",
props: {
"type": "text",
placeholder: "请输入姓名"
},
validate: [
{ required: true, message: '姓名不能为空' },
],
col: {
span: 6,
labelWidth: 100,
'class-name': 'wrap'
},
},
{
type: "radio",
field: "sex",
title: "性别",
value: '1',
options: [
{ "value": "1", "label": "男" },
{ "value": "2", "label": "女" },
],
col: {
span: 6,
labelWidth: 120,
},
validate: [
{ required: true },
],
},
]
},
mounted() {
let that = this
const root = document.getElementById('form-create');
$f = window.formCreate.create(
that.rule,
{
el: root,
resetBtn: true,
onSubmit: function (formData) {
console.log(formData)
}
});
}
})
</script>
</html>