首页 > 其他分享 >vue记事本渲染以及交互

vue记事本渲染以及交互

时间:2024-04-01 13:58:23浏览次数:14  
标签:vue 交互 list li height margin font todo 记事本

以下是记事本的源码

<!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>

标签:vue,交互,list,li,height,margin,font,todo,记事本
From: https://blog.csdn.net/2301_77264434/article/details/137226566

相关文章

  • Vue自定义指令directive(主要是钩子函数及其参数)
    Vue自定义指令directive(主要是钩子函数及其参数):https://blog.csdn.net/weixin_46037781/article/details/119637729?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522171194263116777224467854%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request......
  • vue-router
    [什么是vue-router]传统的路由是针对服务器不同文件,这样路由的变动就会导致新页面加载,导致页面刷新。vue-router实现了在vue组件基础上,不加载页面文件,而是更改部分页面组件的方式来展现不同路由时显示的内容。同时节约了客户端和服务端资源。[安装]npmivue-router@4......
  • App自动化测试:高级控件交互技巧
    简介APP的控件元素不仅涵盖了基础用户界面操作,还包括用户与应用程序中更复杂、功能丰富的空间之间的互动。这种交互远不止于简单的按钮或输入框。通过借助Appium的Actions,能够完成对应用程序进行手势识别的交互。这意味着可以通过各种手势,如滑动、缩放、长按等,实现更灵活、直......
  • vue表单点击按钮增加或者删除一行
    vue表单点击按钮增加或者删除一行不需要动态改变的就不用放在一个form-item中,可以单独写一个form-item。需要点击增加和删除的表单项目可以用v-for来循环渲染。<a-form:label-col="{span:8}":wrapper-col="{span:12}"> <a-form-itemlabel="服务器名称">......
  • 【前端面试3+1】07vue2和vue3的区别、vue3响应原理及为什么使用proxy、vue的生命周期
    一、vue2和vue3的区别1.性能优化:        Vue3在性能方面有很大的提升,主要是通过虚拟DOM的优化和响应式系统的改进实现的。虚拟DOM重构:Vue3中对虚拟DOM进行了重构,使得更新算法更加高效,减少了更新时的开销,提升了性能。静态树提升:Vue3可以通过静态树提升技术......
  • vue3 点击按钮跳转到对应的tab页面
     大家好呀,我又来记录一下啦实现功能:点击”查看“按钮,跳转到对应的tab页面方法:router按钮部分:<el-buttonsize="small"@click="check(scope.row.name)">查看</el-button>对应的方法:check(){this.$router.push({path:'/about'})},router:import......
  • 从虚拟dom知识无痛深入vue与react的原理
     我们都知道像vue、react都有用到虚拟dom,那么虚拟dom到底是什么?框架为什么不直接操作真实dom而要在中间要引入虚拟dom呢?vue和react的虚拟dom又有什么异同呢?我们就从虚拟dom开始讲起,再来逐步引入讲解vue与react的部分原理及其异同,这里会顺便讲解到数据驱动视图及视图驱动数据,......
  • 程序与用户之间交互
    【一】用户交互交互的本质就是输入、输出用户交互就是人往计算机中input/输入数据,计算机print/输出结果【二】为什么要与用户交互为了让计算机能够像人一样与用户沟通交流【三】如何实现交互【1】输入(input)input接受的所有数据类型都是str类型username=input("......
  • vue-路由详解
    路由vue-router1.对路由的理解:vue的一个插件库,专门用来实现SPA应用2.对SPA应用的理解:1.单页web应用2.整个应用只有一个完整的页面(index.html)3.点击页面中的导航链接不会刷新页面,只做页面的局部更新4.数据需要通过ajax请求获取3.什么是路由?1.......
  • Vite + Vue3 项目的创建 ,启动 ,停止
    第一步:使用命令行创建工程在磁盘的合适位置上,创建一个空目录用于存储多个前端项目用vscode打开该目录在vocode中打开命令行运行如下命令npmcreatevite@latest第一次使用vite时会提示下载vite,输入y回车即可,下次使用vite就不会出现了注意:选择vue+JavaScript选项即可......