上源码
- html 片段
```
- js 片段
var vm = new Vue({ el:’#app’, data:{ userData:{ companyName:’’, peopleNumber:’’, tellPlace:’’, tellCity:’’, tellFormat:’’, openFun:[], Contacts:’’, contactTell:’’ }, checkedNames:[] }, methods:{ submit:function(){ var me = this; var data = JSON.stringify(me.userData); console.log(data); } } });
```
- 浏览器器控制台在数据提交时的输出
- 总结
需要注意的一点是在复选框
checkbox
这种的组合时,需要在js
中将userData
中相应的属性openFun
的默认值写成数组,因为这个是数组类型的数据,还有就是在html
中写的时候需要注意每个checkbox
必须得有value
属性,且有相应值