vuejs 70行代碼實現便簽功能

來源:互聯網
上載者:User

標籤:dos   isp   handler   nbsp   功能   str   png   app   hit   

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8">    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"><title>便簽</title><style>#app {font-family: ‘Avenir‘, Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50;margin-top: 60px;}#app input{width: 200px;}#app ul{width: 200px;display: block;margin: 0 auto;line-height: 1.5;padding: 0;list-style: none;text-align: left;margin-top: 10px;}#app ul li{background: aliceblue;color: #000;margin: 5px 0;}#app .done {background: antiquewhite;color: #999}</style></head><body><div id="app">  <h1 v-text="msg"></h1>  <input v-model="dosth" @keyup.13="onEnter" maxlength="10" placeholder="下一次做什嗎?">  <ul>    <li v-for="i in list" :class="{done:i.is_f}" @click=‘changeF(i);‘>      {{i.op}}    </li>  </ul></div></body></html><script src="http://cdn.jsdelivr.net/vue/1.0.7/vue.min.js"></script><script>/*localStorage 相關方法*/var KEY = ‘vue_demo‘;function store_get(){return JSON.parse(window.localStorage.getItem(this.KEY) || ‘[]‘);}function store_set(val){window.localStorage.setItem(this.KEY,JSON.stringify(val));}</script><script>new Vue({  el: ‘#app‘,  data: {      msg: ‘便簽‘,      dosth: ‘‘,      list: store_get()  },  methods : {    changeF:function(i){      i.is_f = !i.is_f;    },    onEnter: function (){      this.list.push({        ‘op‘:this.dosth,        ‘is_f‘:false      });      this.dosth = ‘‘;    }  },  watch:{    list:{      handler: function(val, oldVal){        store_set(val);      },      deep: true    }  }})</script>

  


 

vuejs 70行代碼實現便簽功能

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.