我是靠谱客的博主 默默棒棒糖,这篇文章主要介绍小黑记事本(网页)项目要求代码结构知识点学习注意事项,现在分享给大家,希望可以做个参考。

项目要求

学习背景:学习vue,回顾html和css
在这里插入图片描述

代码结构

主体区域:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!-- 主体区域 --> <section id="todoapp"> <!-- 输入框 --> <header class="header"> <h1>小黑记事本</h1> <input v-model="inputValue" @keyup.enter="add" autofocus="autofocus" autocomplete="off" placeholder="请输入任务" class="new-todo" /> </header> <!-- 列表区域 --> <section class="main"> <ul class="todo-list"> <li class="todo" v-for="(item,index) in list"> <div class="view"> <span class="index">{{ index+1 }}.</span> <label>{{ item }}</label> <button class="destroy" @click="remove(index)"></button> </div> </li> </ul> </section>

脚部统计和清除按钮 以及 底部logo图:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!-- 统计和清空 --> <footer class="footer" > <span class="todo-count"> <strong>{{list.length}}</strong> items left </span> <button class="clear-completed"> Clear </button> </footer> </section> <!-- 底部 --> <footer class="info"> <p> <a href="http://www.itheima.com/"><img src="./img/black.png" alt="" /></a> </p> </footer>

JS部分(vue):

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script> var app = new Vue({ el: "#todoapp", data: { list: ["写代码", "吃饭饭", "睡觉觉"], inputValue: "好好学习,天天向上" }, methods: { add: function () { this.list.push(this.inputValue); }, remove:function(index){ this.list.splice(index,1); } }, }) </script>

知识点学习

css

复制代码
1
2
3
4
5
6
7
8
9
body { //最小和最大宽度 min-width: 230px; max-width: 550px; //抗锯齿渲染 -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

Vue

  1. v-for循环的使用
复制代码
1
2
3
4
5
6
7
8
9
10
<ul> <li v-for="(item,index) in list"> <div> <span>{{ index+1 }}.</span> <label>{{ item }}</label> <button @click="remove(index)"></button> </div> </li> </ul>
  1. v-model双向绑定
复制代码
1
2
3
4
<!-- v-model双向绑定(学习重点),keyup表示松开键盘时触发, --> <input v-model="inputValue" @keyup.enter="add" autofocus="autofocus" autocomplete="off" placeholder="请输入任务" class="new-todo"/>
  1. splice的用法
复制代码
1
2
3
4
5
// splice可以用来删除/添加数组元素 // splice(index,n,"ab","cd")删除从index开始后面的n个元素, //并从索引处添加"ab""cd"两个字符串。 this.list.splice(index,1)

注意事项

Vue创建对象时,Vue的首字母 V 要大写;
写函数是要注意参数的传递。

最后

以上就是默默棒棒糖最近收集整理的关于小黑记事本(网页)项目要求代码结构知识点学习注意事项的全部内容,更多相关小黑记事本(网页)项目要求代码结构知识点学习注意事项内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(88)

评论列表共有 0 条评论

立即
投稿
返回
顶部