JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@1.4.0/lib/index.js"></script>
<div id="app">
<template>
<el-dialog
:visible.sync="dialogVisible"
size="tiny">
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="用户编号" prop="user_id">
<el-input v-model="form.user_id"></el-input>
</el-form-item>
</el-form>
</el-dialog>
<el-button type="primary" @click.native="add">添加</el-button>
<el-button type="primary" @click.native="edit">编辑</el-button>
</template>
</div>
SCSS
@import url("//unpkg.com/element-ui@1.4.0/lib/theme-default/index.css");
Babel + JSX
var Main = {
data() {
return {
dialogVisible:false,
form:{
user_id:""
}
}
},
methods: {
add:function(){
this.dialogVisible = true;
this.$refs['form'].resetFields();
},
edit:function(){
this.dialogVisible = true;
this.$nextTick(() => {
this.form.user_id = "111";
});
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')