1. Main functionsThis task is mainly to use VUE to implement a simple student information management system, the main functions are: 1. Display information of all students (default is 10) 2. Implementation ideas 1. Data management: Use json array to manage and store data 3. Code Implementation1. Parent-child component definition Parent component: First, define the component to be called export default { name: 'HelloWorld', components: ChildCom//Calling component}, Subcomponents: export default { name: 'Child', props: [ 'card_item' ], data () { return { } } } 2. Communication among components Components pass data to subcomponents through Props Parent component: Use v-for to traverse the student information array <div v-if="flag_danshu==1"> <Child-com id="1" class="list" v-for="(stu,index1) in new_list_danshu" :key="index1" :card_item="stu" > </Child-com> </div> <div v-else-if="flag_shuangshu==1"> <Child-com id="2" class="list" v-for="(stu,index2) in new_list_shuangshu" :key="index2" :card_item="stu" > </Child-com> </div> <div v-else-if="flag_all==1"> <Child-com id="3" class="list" v-for="(stu,index3) in stu_list" :key="index3" :card_item="stu"> </Child-com> </div> Subcomponents: <div>Name: {{ card_item.name }} </div> <div>Student ID: {{card_item.stuId}}</div> <div v-if="card_item.gender==1">Gender: Male</div> <div v-else>Gender: Female</div> 3. Display the student information whose student ID ends with an odd number (or even number) (taking odd number as an example) danshu (stu_list) { this.new_list_danshu=[]; stu_list.forEach((item) => { if(item.stuId%2!=0) this.new_list_danshu.push(item);//If the conditions are met, add it to the json array used to store singular information} ) // alert(this.new_list[1]); this.flag_all=0; //Show all this.flag_danshu=1; //Show odd numbers this.flag_shuangshu=0; //Show even numbers}, 4. Add student information 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('Please complete the information'); } else{ var item ={}; item.stuId=id; item.name=name; item.gender=gender; this.stu_list.push(item); alert('Added successfully'); } } 4. Effect displayHome Display student information whose student ID ends in an odd number Add student information V. ConclusionAlthough it is just a small demo, I still encountered many problems in the process of completing it, such as paying attention to the difference between v-show and v-if. At first, I wanted to use v-show to display different student information according to the filtering conditions, but I found that even if the student information did not meet the current conditions, it was still rendered and displayed. After seeking help, I found that if we want to display multiple pages and these pages are mutually exclusive, we use v-if, v-else-if, and v-else to display them. Here are the differences between v-show and v-if
This is the end of this article about implementing a simple student information management system based on VUE. For more relevant vue student information management system content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! This is the end of this article about implementing a simple student information management system based on VUE. For more relevant vue student information management system content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of why v-if and v-for in Vue are not recommended to be used together
>>: Vue uses vue-quill-editor rich text editor and uploads pictures to the server
The project was tested these days, and the tester...
(1) Server configuration: [root@localhost ~]# cd ...
Table of contents 1. Problem 2. Solution 1. Decla...
Introduction to DNMP DNMP (Docker + Nginx + MySQL...
Related reading: Solve the problem that the servi...
This article example shares the specific code of ...
Mini Program Data Cache Related Knowledge Data ca...
What is bond NIC bond is a technology that is com...
Yesterday when I was implementing the function of...
Table of contents this Method In the object Hidde...
Table of contents 1. Docker configuration 2. Crea...
Analyze the execution process. Move the mouse int...
Method 1: Use the SET PASSWORD command MySQL -u r...
Table of contents How to represent the current ti...
Recently, the company is preparing to develop an ...