vue记事本渲染以及交互

以下是记事本的源码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>记事本</title>
    <style>
/* 标题 */
h1{
  margin-top: 130px;
   color: red;
    font-size: 29px;
}

/* 按钮 */
button {
    /* 去掉黑圈 */
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}
/* 主体 */
body {
  line-height: 1.4em;
  background: #f5f5f5;
  color: #4d4d4d;
  min-width: 260px;
  max-width: 600px;
  margin: 0 auto;
  font-weight: 300;
}
/* 输入框 */
.new-todo{
  position: relative;
  margin: 0;
  width: 100%;
  font-size: 24px;
}
/* 列表渲染 */
.todo-list li {
  position: relative;
  font-size: 24px;
  height: 60px;
  box-sizing: border-box;
  border-bottom: 1px solid #e6e6e6;
}
/* 列表渲染 */
.todo-list li {
  word-break: break-all;
  padding: 15px 15px 15px 60px;
  display: block;
  line-height: 1.2;
  transition: color 0.4s;
}
/* 删除按键 */
.todo-list li .destroy {
  display: none;
  position: absolute;
  top: 0;
  right: 10px;
  bottom: 0;
  width: 10px;
  height: 10px;
  font-size: 30px;
  color: black;
  margin-bottom: 11px;
}
/* 删除按键 */
.todo-list li .destroy:after {
  content: 'x';
}
/* 显示删除 */
.todo-list li:hover .destroy {
  display: block;
}
/* 删除 */
.clear-completed {
  float: right;
  position: relative;
  line-height: 20px;
  text-decoration: none;
  cursor: pointer;
}


</style>
</head>
<body>
    <!-- 容器 -->
<section id="todoapp" boder="1">
    <!-- 头部输入框 -->
    <header class="header">
        <h1>小黑记事本</h1>
        <input v-model="inputValue" v-on: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 @click="remove(index)" class="destroy"></button>
            </div>
        </li>
    </ul>
</section>
    <!-- 统计和清空 -->
    <footer class="footer">
        <!-- <span v-if="list.length" class="todo-count">
          <strong>{{ list.length }}</strong>
        </span> -->
        <button v-show="list.length" v-on:click="clear" class="clear-completed">
            全删
          </button>
    </footer>
</section>

</body>
<script src="D:\technology\Technology\vue.js\vue.js"></script>
<script>
// 创建 Vue 实例
let vm = new Vue({
    el:"#todoapp",
    data:{
        list: ["俯卧撑", "跑步", "游泳"],
    },
    methods:{     
        add:function(){
            let data = this.inputValue.trim()
            if (data != "")
                this.list.push(this.inputValue);
            else
                console.log("null");
        },
        remove: function (index)
        {
            console.log("remove", index);
            this.list.splice(index, 1);
        },
        // +
        clear: function ()
        {
            this.list = [];
        }
    }
})

</script>

</html>

相关推荐

  1. vue记事本渲染以及交互

    2024-04-02 12:00:03       16 阅读
  2. Vue-条件渲染(初识vue渲染

    2024-04-02 12:00:03       19 阅读
  3. vue3-条件渲染

    2024-04-02 12:00:03       25 阅读
  4. Vue】列表渲染

    2024-04-02 12:00:03       30 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-02 12:00:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-02 12:00:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-02 12:00:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-02 12:00:03       18 阅读

热门阅读

  1. docker compose部署项目—踩坑记录

    2024-04-02 12:00:03       14 阅读
  2. Linux中的用户和组管理

    2024-04-02 12:00:03       12 阅读
  3. Go-Gin全局错误处理中间件

    2024-04-02 12:00:03       11 阅读
  4. C++ TCP 服务端和客户端通信的例子

    2024-04-02 12:00:03       12 阅读
  5. 前端 prefetch 和 preload 的区别?

    2024-04-02 12:00:03       14 阅读
  6. Yarn 包管理器入门指南

    2024-04-02 12:00:03       14 阅读
  7. linux定时调度任务

    2024-04-02 12:00:03       12 阅读
  8. Hadoop系列总结

    2024-04-02 12:00:03       16 阅读
  9. openGL创建平面、立方体、圆柱体、斜面和棱柱Demo

    2024-04-02 12:00:03       14 阅读
  10. redis-Hash

    2024-04-02 12:00:03       15 阅读