vue簡(jiǎn)易記事本開(kāi)發(fā)詳解
本文實(shí)例為大家分享了vue實(shí)現(xiàn)易記事本的具體代碼,供大家參考,具體內(nèi)容如下
css代碼
#todoapp { margin: 0 400px; width: 600px; background-color: gray; text-align: center;}.content { margin:0px 100px;}.todo { margin: 10px; text-align: left; background-color:green;}.btn { float: right; background-color: lawngreen;}.clear{ background-color: lightseagreen;}.list{ margin-left: 10px;}
html代碼加js代碼
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <meta name='viewport' content='width=device-width, initial-scale=1.0'> <title>Document</title> <link rel='stylesheet' href='http://www.intensediesel.com/bcjs/css/index.css' > <script src='http://www.intensediesel.com/bcjs/js/vue.js' type='text/javascript' charset='utf-8'></script></head><body> <div id='todoapp'> <div class='header'><h1>小黑記事本</h1><input type='text' v-model='inputValue' placeholder='請(qǐng)輸入任務(wù)'> <button @click='add'>添加</button> </div> <div class='content'><ul v-for='(item,index) in list'> <div class='todo'><span class='index'>{{index+1}}</span><label class='list'>{{item}}</label><button @click='remove(index)'>刪除</button> </div> </ul> </div> <div> <button @click='clearBoth' class='clear'>全部清除</button> </div> </div> <script>var app = new Vue({ el:'#todoapp', data: { list:['吃飯飯','打游戲','吃西瓜'], inputValue:'' }, methods: {remove:function(index){ this.list.splice(index,1)},add: function () { this.list.push(this.inputValue)},clearBoth:function(){ this.list.splice(0,this.list.length)} }}) </script></body></html>
運(yùn)行效果截圖
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. ASP.NET MVC遍歷驗(yàn)證ModelState的錯(cuò)誤信息2. JavaScript實(shí)現(xiàn)組件化和模塊化方法詳解3. .Net Core和RabbitMQ限制循環(huán)消費(fèi)的方法4. ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向5. ASP中if語(yǔ)句、select 、while循環(huán)的使用方法6. asp中response.write("中文")或者js中文亂碼問(wèn)題7. jsp網(wǎng)頁(yè)實(shí)現(xiàn)貪吃蛇小游戲8. PHP設(shè)計(jì)模式中工廠模式深入詳解9. 刪除docker里建立容器的操作方法10. asp(vbs)Rs.Open和Conn.Execute的詳解和區(qū)別及&H0001的說(shuō)明
