久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

vue簡(jiǎn)易記事本開發(fā)詳解

瀏覽:15日期:2022-09-28 16:12:00

本文實(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.baoyu77737.com/bcjs/css/index.css' > <script src='http://www.baoyu77737.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)行效果截圖

vue簡(jiǎn)易記事本開發(fā)詳解

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 和政县| 澄迈县| 绿春县| 阿克苏市| 扶风县| 莎车县| 明溪县| 梁山县| 蒲江县| 上杭县| 萝北县| 清涧县| 泰和县| 朝阳区| 黄平县| 靖宇县| 望谟县| 林口县| 比如县| 岫岩| 玉屏| 郎溪县| 阳西县| 大足县| 手游| 临清市| 巧家县| 元谋县| 北海市| 射洪县| 界首市| 高安市| 肃南| 兴文县| 同江市| 岳池县| 根河市| 石门县| 仙居县| 彭阳县| 利津县|