vue实现员工信息录入功能的方法


本文摘自PHP中文网,作者coldplay.xixi,侵删。

Vue通用信息录入界面,供大家参考,具体内容如下


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

<!DOCTYPE html>

<html lang="en">

<head>

 <meta charset="UTF-8">

 <title>员工信息录入</title>

 

 <style>

 

 .btn1{

  color: blue;

  background: skyblue;

  text-align: center;

 }

 

 </style>

</head>

<body>

 

 <p id="p2">

 

 <fieldset>

  <legend>员工信息录入</legend>

 

 

  <p >

 

  <label>姓名:</label>

  <input type="text" v-model="newStudent.name"><br>

  <label>年龄:</label>

  <input type="text" v-model="newStudent.age"><br>

 

  <label>性别:</label>

  <select v-model="newStudent.sex">>

   <option value="男">男</option>

   <option value="女">女</option>

  </select><br>

  <label>手机:</label>

  <input type="text" v-model="newStudent.phoneNo"><br>

  <p>

  <button @click="createStudent()">新增用户</button>

  </p>

 

  </p>

 

 

  <table border="2px">

  <thead>

   <tr>

   <th>序号</th>

   <th>姓名</th>

   <th>年龄</th>

   <th>性别</th>

   <th>手机</th>

   <th>操作</th>

   </tr>

 

  </thead>

 

  <tbody>

   <tr v-for="(student,index) in studentsList">

   <td>{{index+1}}</td>

   <td>{{student.name}}</td>

   <td>{{student.age}}</td>

   <td>{{student.sex}}</td>

   <td>{{student.phoneNo}}</td>

   <td :class="btn1"><button @click="DeletestudentRow(index)">移除</button></td>

   </tr>

 

 

  </tbody>

 

 

  </table>

  <label>总行数:</label><span>{{studentsList.length}}</span>

 

 </fieldset>

 

 

 </p>

 

 

 

</body>

<script src="js/vue.js"></script>

<script>

 

 var p1Data={

 newStudent:{name:"",age:0,sex:"男",phoneNo:""},

 studentsList:[{No:"0001",name:"张三",age:18,sex:"男",phoneNo:"13688899900"},

  {No:"0112",name:"王五",age:28,sex:"男",phoneNo:"18800068888"},

  {No:"0253",name:"林志玲",age:33,sex:"女",phoneNo:"18600001002"},

  {No:"0608",name:"林志颖",age:68,sex:"男",phoneNo:"15998769900"}],

 };

 

 

 var vm1=new Vue({

 el:"#p2",

 data:p1Data,

 

 methods:{

 

  //移除一行

  DeletestudentRow:function (index) {

  this.studentsList.splice(index,1);

  },

 

 

  //添加一行

  createStudent: function(){

  this.studentsList.push(this.newStudent);

  // 添加完newPerson对象后,重置newPerson对象

  this.newStudent = {name:"",age:0,sex:"男",phoneNo:""}

  },

 

 

 }

 

 

 

 });

 

 

</script>

</html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关学习推荐:javascript视频教程

以上就是vue实现员工信息录入功能的方法的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

javascript怎么删除数组的指定元素

javascript怎么设置表单只读

javascript是什么

通过javascript函数生成字符串的所有排列组合

浅谈javascript中数组array的添加/删除操作

javascript如何使网页跳转

popper.js怎么下载

javascript返回值是什么

javascript怎么保留两位小数

教你一招网课作业如何复制粘贴

更多相关阅读请进入《javascript》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...