Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement a simple student information management system with VUE

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

本篇内容主要讲解"怎么用VUE实现一个简单的学生信息管理系统",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"怎么用VUE实现一个简单的学生信息管理系统"吧!

一、主要功能

本次任务主要是使用 VUE 来实现一个简单的学生信息管理系统,主要功能为:

1.显示所有学生的信息(默认为10个) \2. 点击按钮,显示出学号尾号为单数(或双数)的学生信息 \3. 增加学生信息 \4. 要求使用VUE中 父子组件间通信

二、实现思路

1.数据管理:使用 json 数组的方式来管理储存数据

2.显示学生信息:因为组件是可复用的 Vue 实例,所以在这里引入子组件(用来显示每个学生的信息),将主页作为父组件。主页(父组件)使用 v-for 循环显示子组件。

3.按单双号筛选查找学生:循环遍历 json 数组,进行判断,把符合条件的信息放到新的 json 数组。

4.使用 v-if 把符合筛选条件的学生信息显示在主页上。

三、代码实现

1、父子组件定义

父组件 :首先要定义要调用的组件

export default {

name: 'HelloWorld',

components: {

ChildCom//调用组件

},

子组件:

export default {

name: 'Child',

props: [

'card_item'

],

data () {

return {

}

}

}

2、组件中的通信

组件是通过 Prop 向子组件传递数据的

父组件:使用 v-for 遍历学生信息数组 通过:card_item(子组件定义的接受数据的名字) = "stu"(父组件传给子组件的数据)

子组件:

姓名:{{ card_item.name }}

学号:{{card_item.stuId}}

性别:男

性别:女

3、显示出学号尾号为单数(或双数)的学生信息(以单数为例)

danshu (stu_list) {

this.new_list_danshu=[];

stu_list.forEach((item) => {

if(item.stuId%2!=0)

this.new_list_danshu.push(item);//符合条件则加进用来存储单数信息的json数组

}

)

// alert(this.new_list[1]);

this.flag_all=0; //显示全部

this.flag_danshu=1;//显示单数

this.flag_shuangshu=0;//显示双数

},

4、增加学生信息

add:function(){

var name = document.getElementById("stu_name").value;

var id = document.getElementById("stu_id").value;

var gender = document.getElementById("stu_gender").value;

if(name==''||id==''||gender==''){

alert('请完善信息');

}

else{

var item ={};

item.stuId=id;

item.name=name;

item.gender=gender;

this.stu_list.push(item);

alert('添加成功');

}

}到此,相信大家对"怎么用VUE实现一个简单的学生信息管理系统"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report