国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

Vue記事本實(shí)例詳解

發(fā)布時(shí)間:2021-08-17 12:16 來(lái)源: 閱讀:0 作者:影修 欄目: JavaScript 歡迎投稿:712375056

本文實(shí)例為大家分享了Vue實(shí)現記事本功能的具體代碼,供大家參考,具體內容如下

實(shí)例功能點(diǎn)不多,主要難點(diǎn)在于筆記文本對象數組的添加,刪除,以及對組件的綁定同步事件。

核心代碼

<section id="todoapp">
      <!-- 輸入框 -->
      <header class="header">
        <h1>記事本</h1>
        <input
                v-model="note"
          autofocus="autofocus"
          autocomplete="off"
          placeholder="請輸入任務(wù)"
          class="new-todo"
        />
        <div style="text-align: right;width: 90%;height: 3%;">
          <button value="記錄" style="text-align: center" @click="addnote">記錄</button>
        </div>

      </header>
      <!-- 列表區域 -->
      <section class="main">
        <ul class="todo-list">
          <li class="todo" 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>
      <!-- 統計和清空 -->
      <footer class="footer">
        <span class="todo-count"><strong>{{notes.length}}</strong> items left </span>
        <button class="clear-completed" @click="delnote">
          Clear
        </button>
      </footer>
    </section>
      <script>
      let vue = new Vue({
        el:"#todoapp",
        data:{
          note:"好好學(xué)習,天天向上",
          index:0,
          notes:[
                  "寫(xiě)代碼",
                  "吃飯飯",
                  "睡覺(jué)覺(jué)"
          ]
        },
        methods:{
          addnote:function () {
            this.notes.push(this.note);
          },
          delnote:function () {
            this.notes = [];
          }
        }
      });
</script>

關(guān)于vue.js組件的教程,請大家點(diǎn)擊專(zhuān)題進(jìn)行學(xué)習。

以上就是本文的全部?jì)热?,希望對大家的學(xué)習有所幫助,也希望大家多多支持腳本之家。

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

亚洲中文字幕久久精品无码喷水| 久青草影院在线观看国产| 成人A级毛片免费观看| 日韩免费A级毛片无码A∨| 亚洲国产AV无码综合原创国产| 成全动漫视频在线观看完整版|