Vue記事本實(shí)例詳解
本文實(shí)例為大家分享了Vue實(shí)現(xiàn)記事本功能的具體代碼,供大家參考,具體內(nèi)容如下
實(shí)例功能點(diǎn)不多,主要難點(diǎn)在于筆記文本對象數(shù)組的添加,刪除,以及對組件的綁定同步事件。
核心代碼
<section id='todoapp'> <!-- 輸入框 --> <header class='header'><h1>記事本</h1><inputv-model='note' autofocus='autofocus' autocomplete='off' placeholder='請輸入任務(wù)' /><div style='text-align: right;width: 90%;height: 3%;'> <button value='記錄' @click='addnote'>記錄</button></div> </header> <!-- 列表區(qū)域 --> <section class='main'><ul class='todo-list'> <li v-for='(n,index) in notes'> <div class='view'> <span class='index'>{{index+1}}</span> <label>{{n}}</label> <button class='destroy'></button> </div> </li></ul> </section> <!-- 統(tǒng)計(jì)和清空 --> <footer class='footer'><span class='todo-count'><strong>{{notes.length}}</strong> items left </span><button @click='delnote'> Clear</button> </footer> </section> <script> let vue = new Vue({el:'#todoapp',data:{ note:'好好學(xué)習(xí),天天向上', index:0, notes:[ '寫代碼', '吃飯飯', '睡覺覺' ]},methods:{ addnote:function () { this.notes.push(this.note); }, delnote:function () { this.notes = []; }} });</script>
關(guān)于vue.js組件的教程,請大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. ASP基礎(chǔ)知識VBScript基本元素講解2. Python requests庫參數(shù)提交的注意事項(xiàng)總結(jié)3. ajax請求添加自定義header參數(shù)代碼4. IntelliJ IDEA導(dǎo)入jar包的方法5. Gitlab CI-CD自動(dòng)化部署SpringBoot項(xiàng)目的方法步驟6. Kotlin + Flow 實(shí)現(xiàn)Android 應(yīng)用初始化任務(wù)啟動(dòng)庫7. 詳談ajax返回?cái)?shù)據(jù)成功 卻進(jìn)入error的方法8. python操作mysql、excel、pdf的示例9. vue-electron中修改表格內(nèi)容并修改樣式10. python爬蟲學(xué)習(xí)筆記之pyquery模塊基本用法詳解
