Home Web Front-end JS Tutorial Example analysis of Vue implementation of household registration management system

Example analysis of Vue implementation of household registration management system

Jul 17, 2020 pm 05:38 PM
vue

Example analysis of Vue implementation of household registration management system

The example in this article shares with you the specific code of Vue to implement the household registration management system for your reference. The specific content is as follows

Household registration management system, v-model, v- Reference for for

Interface preview

Step ideas:

1.html css creation

2.Introduce vue, example

3.Prepare default data message array

4.Render default data, v-for loop form

5.Create a new data newmessage

6. Bind to the input box v-model

7. Create an add function add() to add new data to the default data, newmessage->message

8. After adding, clear the form and restore newmessage

9. Click who deletes whom del() function

body part:

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<p id = &#39;app&#39; v-cloak>
 <legend>户籍管理系统</legend></br>
 姓名:<input type="text" placeholder="请输入用户名" v-model = &#39;newmessage.name&#39;></br>
 年龄:<input type="text" placeholder="请输入年龄" v-model = &#39;newmessage.age&#39;></br>
 性别:
 <select v-model = &#39;newmessage.sex&#39;>
 <option>男</option>
 <option>女</option>
 </select></br>
 手机:<input type="text" placeholder="请输入手机号" v-model = &#39;newmessage.phone&#39;></br>
 <button class = &#39;save&#39; @click = &#39;add()&#39;>保存至用户</button></br>
 <table>
 <tr class = &#39;title&#39;>
 <td width = &#39;100px&#39;>姓名</td>
 <td width = &#39;100px&#39;>性别</td>
 <td width = &#39;100px&#39;>年龄</td>
 <td width = &#39;200px&#39;>手机</td>
 <td width = &#39;100px&#39;>删除</td>
 </tr>
 <tr v-for = &#39;item,index in message&#39;>
 <td>{{item.name}}</td>
 <td>{{item.sex}}</td>
 <td>{{item.age}}</td>
 <td>{{item.phone}}</td>
 <td><button @click = &#39;del(index)&#39;>删除</button></td>
 </tr>
 </table>
</p>
Copy after login

vue part:

<script>
 var app = new Vue({
 el:&#39;#app&#39;,
 data:{
 message:[
  {
  name:&#39;张三&#39;,
  sex:&#39;女&#39;,
  age:16,
  phone:&#39;1568888811&#39;
  },
  {
  name:&#39;李四&#39;,
  sex:&#39;男&#39;,
  age:26,
  phone:&#39;1456666622&#39;
  },
  {
  name:&#39;王麻子&#39;,
  sex:&#39;女&#39;,
  age:36,
  phone:&#39;1866666666&#39;
  },
 ],
 newmessage:{name:&#39;&#39;,age:&#39;&#39;,sex:&#39;男&#39;,phone:&#39;&#39;},
 
 },
 methods:{
 add(){
  if(!this.newmessage.name == &#39;&#39;){
  this.message.push(this.newmessage);
  this.newmessage = {
  name:&#39;&#39;,
  age:&#39;&#39;,
  sex:&#39;男&#39;,
  phone:&#39;&#39;
  };
  }
  else{
  alert(&#39;请输入姓名!&#39;);
  }
 },
 del(index){
  this.message.splice(index,1);
 }
 }
 })
 </script>
Copy after login

css style:

<style>
 *{
 margin:0;
 padding:0;
 }
 #app{
 border: 1px solid black;
 width:800px;
 padding:30px 30px;
 }
 #app .save{
 background-color: #555555;
 border-radius: 10%;
 height:50px;
 color:white;
 }
 #app input,select{
 margin:10px 0;
 width:300px;
 }
 #app td{
 text-align: center;
 }
 #app .title td{
 background-color: #555555;
 color:white;
 }
 #app table button{
 background-color: #555555;
 color:white;
 border-radius: 30%;
 }
 </style>
Copy after login

Related learning recommendations: javascript video tutorial

The above is the detailed content of Example analysis of Vue implementation of household registration management system. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

From PHP to Go or Front-end? The suggestions and confusions of reality from experienced people From PHP to Go or Front-end? The suggestions and confusions of reality from experienced people Apr 01, 2025 pm 02:12 PM

Confusion and the cause of choosing from PHP to Go Recently, I accidentally learned about the salary of colleagues in other positions such as Android and Embedded C in the company, and found that they are more...

How to implement panel drag and drop adjustment function similar to VSCode in front-end development? How to implement panel drag and drop adjustment function similar to VSCode in front-end development? Apr 04, 2025 pm 02:06 PM

Explore the implementation of panel drag and drop adjustment function similar to VSCode in the front-end. In front-end development, how to implement VSCode similar to VSCode...

How to manually trigger the onBlur event of a cell in Avue-crud row editing mode? How to manually trigger the onBlur event of a cell in Avue-crud row editing mode? Apr 04, 2025 pm 02:00 PM

The onBlur event that implements Avue-crud row editing in the Avue component library manually triggers the Avue-crud component. It provides convenient in-line editing functions, but sometimes we need to...

Vue Element uploads large files online errors: How to troubleshoot cross-domain problems and other potential causes? Vue Element uploads large files online errors: How to troubleshoot cross-domain problems and other potential causes? Apr 01, 2025 pm 12:48 PM

Vue Elementel-upload upload file online error reporting and troubleshooting using Vue and Element...

Is the convergence of the technology stack the selection of the technology stack? Is the convergence of the technology stack the selection of the technology stack? Apr 02, 2025 pm 04:42 PM

Title: The relationship between technology stack convergence and selection: Does technology stack convergence refer to the selection of technology stack? I saw an article that has a convergence technology stack...

Is the convergence of technology stack the selection of technology stack? Is the convergence of technology stack the selection of technology stack? Apr 02, 2025 am 11:54 AM

Discussion on the relationship between technology stack convergence and selection In technology development, problems about technology stack convergence and selection are often encountered. So, is the technology stack converging...

How to use Vue 3 to implement up scrolling loading function similar to WeChat chat records? How to use Vue 3 to implement up scrolling loading function similar to WeChat chat records? Apr 04, 2025 pm 03:51 PM

How to achieve upward scrolling loading similar to WeChat chat records? When developing applications similar to WeChat chat records, a common question is how to...

Should PHP developers switch to Go or to front-end? Should PHP developers switch to Go or to front-end? Apr 02, 2025 pm 04:57 PM

Career choices for PHP developers: to switch to Go or to front-end? In the modern software development industry, the selection of technology stacks and the planning of career development paths are for...

See all articles