欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue.js實現(xiàn)備忘錄功能

 更新時間:2019年06月26日 08:32:49   作者:zk_813  
這篇文章主要為大家詳細(xì)介紹了Vue.js實現(xiàn)備忘錄功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Vue.js實現(xiàn)備忘錄的具體代碼,供大家參考,具體內(nèi)容如下

效果展示:

html代碼:

<!DOCTYPE html>
<html>
 <head>
 <meta charset="utf-8">
 <!-- 移動設(shè)備設(shè)置 -->
 <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
 <title>記事本</title>
 <link rel="stylesheet" type="text/css" href="css/noteUI.css" >
 <!-- vue核心框架 -->
 <script src="vue/vue.js" type="text/javascript" charset="UTF-8"></script>
 <script src="vue/vue-resource.min.js" type="text/javascript" charset="UTF-8"></script>
 </head>
 <body>
 
 <div id="app">
 <!-- 一般用于頭部 -->
 <header>
 <h1>備忘錄<span class="right">{{now}}</span></h1>
 </header>
 <section>
 <!-- 多行文本 -->
 <!-- 視圖傳數(shù)據(jù) -->
 <!-- v-model="diary"雙向數(shù)據(jù)綁定 -->
 <textarea v-model="diary" style="width: 100%;height: 200px;" placeholder="寫日記是一個好習(xí)慣">
 </textarea>
 <!-- @click='finished'綁定methods屬性中的方法 -->
 <button @click="finished" class="finish">完成</button>
 </section>
 <ul>
 <!-- 循環(huán)遍歷data中的noteooks屬性B,每次循環(huán)都賦值給nb -->
 <!-- v-for="(數(shù)組值,數(shù)組下標(biāo)) in noteBooks"-->
 <li v-for="(nb,i) in noteBooks">
  <!--nb.txt類似對象訪問-->
  <!-- v-html="nb.txt"綁定html代碼 -->
  <p v-html="nb.txt">寫日記是一個好習(xí)慣</p>
  <div class="btn_ground">
  <button @click="del" type="button" class="del left">刪除</button>
  <!-- v-text="nb.time" 綁定文本等價于 {{nb.time}}-->
  <span class="time" v-text="nb.time"></span>
  <button @click="upDate(i)" type="button" class="update right">修改</button>
  </div>
 </li>
 </ul>
 </div>
 <footer>
 版權(quán)所有 zk
 </footer>
 <script src="noteBook.js" type="text/javascript" charset="UTF-8"></script>
 
 </body>
</html>

CSS代碼:

*{
 margin: 0;
 padding:0;
}
header,#app,footer{
 margin:0 8px;
}
header h1{
 color: #FF4500;
 font-weight: normal;
 font-size: 24px;
 padding-top: 10px;
 padding-bottom: 4px;
 border-bottom: 1px solid #ccc;
 margin-bottom: 4px;
}
 
#app textarea{
 width: 100%;
 height: 200px;
 border: none;
 border-bottom: 1px solid #ccc;
 padding: 8px 4px;
}
button{
 padding: 4px;
 background-color: #fff;
 border: 1px solid #ccc;
 border-radius: 4px;
}
/* position: relative;沒有脫離正常流 */
/* relitive相對于自己在流中的元素定位 */
/* relative一般用于位置微調(diào),或者讓absolute參考自己定位 */
#app section{
 position: relative;
 
}
.finish{
 position: absolute;
 background-color: limegreen;
 bottom: 8px;
 right: 4px;
}
#app ul{
 margin-top: 8px;
}
#app li{
 border-bottom: 1px solid #CCCCCC;
 margin-bottom: 8px;
}
.left{
 float: left;
}
.right{
 float: right;
}
/* 組合選擇器 */
 
header span.right{
 font-size: 14px;
 padding-top:13px;
}
.btn_ground{
 height: 30px;
 margin-top: 4px;
}
.del{
 background-color: orangered;
 color: #FFFFFF;
}
.update{
 background-color: royalblue;
 color: #FFFFFF;
}
footer{
 color: #999;
 text-align: center;
 font-size: 12px;
}

js代碼:

function getNowString(){
 var now=new Date()
 var arr=['日','一','二','三','四','五','六']
 
 return now.toLocaleDateString()
  +'星期'
 +arr[now.getDay()]
}
 
var App = new Vue({
 el:'#app',
 data:{
 now:getNowString(),
 noteBooks:[
 {
 time:'2019/6/17 星期一',
 txt:'今天天氣不好'
 },{
 time:'2019/6/18 星期二',
 txt:'今天學(xué)習(xí)<i style="color:red">Adidas'
 }
 ],
 diary:'',
 index:'-1'
 },
 methods:{
 finished:function(){
 //!App.diary是考慮App.diary=null的情況
 if(!App.diary||0==App.diary.length)return
 
 if(-1==App.index){
 //存入noteBooks中
 //unshift插入到數(shù)組首位
 App.noteBooks.unshift({
  time:App.now,
  txt:App.diary
 })
 }else{
 //修改
 App.noteBooks[App.index]={
  time:App.now,
  txt:App.diary
 }
 App.index=-1
 }
 App.diary = ''
 App.now=getNowString()
 },
 del:function(i){
 // 刪除 splice(起始下標(biāo),刪除個數(shù))
 App.noteBooks.splice(i,1)
 },
 upDate:function(i){
 var nb=App.noteBooks[i]
 App.diary=nb.txt
 App.now = nb.time
 //App.index 為-1表示新增,其他就是修改
 App.index=i
 }
 }
})

 以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue中destroyed方法的使用說明

    vue中destroyed方法的使用說明

    這篇文章主要介紹了vue中destroyed方法的使用說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07
  • 一文詳解Vue3中簡單diff算法的實現(xiàn)

    一文詳解Vue3中簡單diff算法的實現(xiàn)

    這篇文章主要為大家詳細(xì)介紹Vue3中簡單diff算法的實現(xiàn)與使用,文中的示例代碼講解詳細(xì),具有一定的借鑒價值,感興趣的可以了解一下
    2022-09-09
  • VUE里如何修改element-ui的顯示層次與上下間隔

    VUE里如何修改element-ui的顯示層次與上下間隔

    這篇文章主要介紹了VUE里如何修改element-ui的顯示層次與上下間隔問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • vue 動態(tài)組件用法示例小結(jié)

    vue 動態(tài)組件用法示例小結(jié)

    這篇文章主要介紹了vue 動態(tài)組件用法,結(jié)合實例形式總結(jié)分析了vue 動態(tài)組件基本功能、原理、使用方法及操作注意事項,需要的朋友可以參考下
    2020-03-03
  • Vue 2.0 偵聽器 watch屬性代碼詳解

    Vue 2.0 偵聽器 watch屬性代碼詳解

    這篇文章主要介紹了Vue 2.0 偵聽器 watch屬性代碼詳解,本文通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值 ,需要的朋友可以參考下
    2019-06-06
  • Vue Router初始化路由信息詳解

    Vue Router初始化路由信息詳解

    這篇文章主要為大家詳細(xì)介紹了Vue Router初始化路由信息的相關(guān)知識,文中的示例代碼講解詳細(xì),具有一定的借鑒價值,感興趣的小伙伴可以了解一下
    2023-11-11
  • vue-virtual-scroll-list虛擬組件實現(xiàn)思路詳解

    vue-virtual-scroll-list虛擬組件實現(xiàn)思路詳解

    這篇文章主要給大家介紹了關(guān)于vue-virtual-scroll-list虛擬組件實現(xiàn)思路的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2023-02-02
  • 組件中多個el-upload存在導(dǎo)致上傳圖片失效的問題及解決

    組件中多個el-upload存在導(dǎo)致上傳圖片失效的問題及解決

    這篇文章主要介紹了組件中多個el-upload存在導(dǎo)致上傳圖片失效的問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • Vue中父子組件通訊之todolist組件功能開發(fā)

    Vue中父子組件通訊之todolist組件功能開發(fā)

    這篇文章主要介紹了Vue中父子組件通訊——todolist組件功能開發(fā)的相關(guān)知識,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-05-05
  • vue中的自定義指令clickOutside

    vue中的自定義指令clickOutside

    這篇文章主要介紹了vue中的自定義指令clickOutside,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-05-05

最新評論