vue實(shí)現(xiàn)form表單與table表格的數(shù)據(jù)關(guān)聯(lián)功能示例
本文實(shí)例講述了vue實(shí)現(xiàn)form表單與table表格的數(shù)據(jù)關(guān)聯(lián)功能。分享給大家供大家參考,具體如下:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>chabaoo.cn vue form表單數(shù)據(jù)關(guān)聯(lián)</title> <style> *{ margin: 0; padding: 0; list-style: none; } input{ margin-left: 50px ; } span{ margin-left: 50px ; } select{ margin-left: 50px ; } .create{ margin-left: 150px ; } </style> </head> <body> <form id="app"> <fieldset> <legend>Creat New Person</legend> <span>Name:</span><input type="text" v-model="text0"> <br> <span>Age:</span><input type="text" value="0" v-model="text1"> <br> <span>Sex:</span><select v-model="text2"> <option>Man</option> <option>Woman</option> <option>....</option> </select> <br> <button class="create" @click="add">Create</button> </fieldset> <table> <tr><td>Name</td><td>Age</td><td>Sex</td><td>Delete</td></tr> <tr v-for="x in person"><td>{{x.name}}</td><td>{{x.age}}</td><td>{{x.sex}}</td><td><button @click="fun">Delete</button></td></tr> </table> </form> </body> <script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script> <script> const app=new Vue({ el:"#app", data:{ text0:"", text1:"", text2:"", person:[{ name:"Jack", age:"20", sex:"man", }, { name:"Bill", age:"24", sex:"woman", }, ] }, methods: { add(){ if (this.text0==""||this.text1==""){ alert("Name Or Age undefined") }else{ this.person.push({ name: this.text0, age: this.text1, sex: this.text2, }); } }, fun(){ this.person.pop() } } }) </script> </html>
運(yùn)行效果如下圖所示:
希望本文所述對(duì)大家vue.js程序設(shè)計(jì)有所幫助。
相關(guān)文章
詳解element上傳組件before-remove鉤子問題解決
這篇文章主要介紹了詳解element上傳組件before-remove鉤子問題解決,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04vue項(xiàng)目如何引入json數(shù)據(jù)
這篇文章主要介紹了vue項(xiàng)目如何引入json數(shù)據(jù),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10Vue + better-scroll 實(shí)現(xiàn)移動(dòng)端字母索引導(dǎo)航功能
better-scroll 是一款重點(diǎn)解決移動(dòng)端(已支持 PC)各種滾動(dòng)場(chǎng)景需求的插件。這篇文章主要介紹了Vue + better-scroll 實(shí)現(xiàn)移動(dòng)端字母索引導(dǎo)航功能,需要的朋友可以參考下2018-05-05vue項(xiàng)目啟動(dòng)后沒有局域網(wǎng)地址問題
這篇文章主要介紹了vue項(xiàng)目啟動(dòng)后沒有局域網(wǎng)地址問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-09-09Vue3 的響應(yīng)式和以前有什么區(qū)別,Proxy 無敵?
這篇文章主要介紹了Vue3 的響應(yīng)式和以前有什么區(qū)別,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05vue實(shí)現(xiàn)商品列表的添加刪除實(shí)例講解
在本篇內(nèi)容里小編給大家分享的是關(guān)于vue實(shí)現(xiàn)商品列表的添加刪除實(shí)例講解,有興趣的朋友們可以參考下。2020-05-05