vue實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
本文實(shí)例為大家分享了vue實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
界面

代碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue--學(xué)生信息管理系統(tǒng)</title>
<!-- 引包 -->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<style>
.title{margin:20px;font-weight: bold;font-size: 20px;}
</style>
</head>
<body>
<div id="app">
<!-- 通過(guò):style設(shè)置樣式 -->
<table :style="[render_table]">
<!-- 通過(guò):class設(shè)置樣式 -->
<caption :class="['title']">學(xué)生信息管理系統(tǒng)</caption>
<tr>
<td>學(xué)號(hào)</td>
<td>姓名</td>
<td>年齡</td>
<td>操作</td>
</tr>
<!-- 遍歷數(shù)據(jù) -->
<tr v-for="(stu,i) in list">
<td><input type="text" v-model="stu.no"></td>
<td><input type="text" v-model="stu.name"></td>
<td><input type="text" v-model="stu.age"></td>
<!-- 綁定點(diǎn)擊事件并傳參 -->
<td><input type="button" value="刪除" @click="del(i)"></td>
</tr>
</table>
<!-- 添加數(shù)據(jù)的表單 -->
<div :style="[render_form]">
<input type="search" v-model="no" placeholder="學(xué)號(hào)"><br>
<input type="search" v-model="name" placeholder="姓名"><br>
<input type="search" v-model="age" placeholder="年齡"><br>
<input type="button" value="添加" @click="add">
</div>
<!-- 用來(lái)顯示雙向數(shù)據(jù)綁定后的編輯效果,數(shù)據(jù)驅(qū)動(dòng)視圖 -->
<div>
<h2>全部數(shù)據(jù)</h2>
<ul v-for="(stu,i) in list">
<!--用三種方式獲取數(shù)據(jù) -->
<li>{{stu.no}}</li>
<li v-text="stu.name"></li>
<li v-html="stu.age"></li>
</ul>
</div>
</div>
<script>
//創(chuàng)建一個(gè)Vue的實(shí)例
var vm = new Vue({
el: "#app", //獲取根節(jié)點(diǎn)
data: {
no:"",
name:"",
age:"",
list:[
{
no:"001",
name:"TOM",
age:18,
},{
no:"002",
name:"Juy",
age:19,
},
{ no:"003",
name:"Mlo",
age:20,
}
],
//設(shè)置樣式
render_table:{"width":"700px","text-align":"center"},
render_form:{"width":"300px","text-align":"center","margin-top":"50px"}
},
methods:{
// 添加方法
add(){
this.list.push({no:this.no,name:this.name,age:this.age});
this.no="";this.name="";this.age="";
},
//刪除方法
del(i){
if(confirm("確定刪除嗎?")){
this.list.splice(i,1);
}
}
}
})
</script>
</body>
</html>
知識(shí)點(diǎn)
- 雙向數(shù)據(jù)綁定
- 文本插值
- 事件綁定
- 方法定義
- 數(shù)據(jù)遍歷
- 樣式設(shè)置
更多文章可以點(diǎn)擊《Vue.js前端組件學(xué)習(xí)教程》學(xué)習(xí)閱讀。
關(guān)于vue.js組件的教程,請(qǐng)大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。
更多vue學(xué)習(xí)教程請(qǐng)閱讀專題《vue實(shí)戰(zhàn)教程》
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
當(dāng)啟動(dòng)vue項(xiàng)目安裝依賴時(shí)報(bào)錯(cuò)的解決方案
這篇文章主要介紹了當(dāng)啟動(dòng)vue項(xiàng)目安裝依賴時(shí)報(bào)錯(cuò)的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-04-04
vue項(xiàng)目實(shí)例中用query傳參如何實(shí)現(xiàn)跳轉(zhuǎn)效果
這篇文章主要介紹了vue項(xiàng)目實(shí)例中用query傳參如何實(shí)現(xiàn)跳轉(zhuǎn)效果,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10
Vue使用$attrs實(shí)現(xiàn)爺爺直接向?qū)O組件傳遞數(shù)據(jù)
這篇文章主要為大家詳細(xì)介紹了Vue如何使用$attrs實(shí)現(xiàn)爺爺直接向?qū)O組件傳遞數(shù)據(jù),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2024-02-02
vue如何解決watch和methods值執(zhí)行順序問(wèn)題
這篇文章主要介紹了vue如何解決watch和methods值執(zhí)行順序問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-08-08
vue實(shí)現(xiàn)table表格里面數(shù)組多層嵌套取值
這篇文章主要介紹了vue實(shí)現(xiàn)table表格里面數(shù)組多層嵌套取值,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08
vuecli+AXdownload下載組件封裝?+css3下載懸浮球動(dòng)畫(huà)效果
當(dāng)觸發(fā)下載功能的時(shí)候,會(huì)觸發(fā)一個(gè)下載動(dòng)畫(huà),下載懸浮球會(huì)自動(dòng)彈出,并且閃爍提示有新的下載任務(wù)直到下載任務(wù)完場(chǎng)提示,接下來(lái)通過(guò)本文介紹vuecli+AXdownload下載組件封裝?+css3下載懸浮球動(dòng)畫(huà)效果,需要的朋友可以參考下2024-05-05

