前端学习(1734):前端系列javascript之添加动画

<template><view class="content"><!-- 状态栏 --><view v-if="list.length !== 0" class="todo-header"><!-- 状态栏的左侧 --><view class="todo-header__left"><text class="active-text">{{text}}</text><text>{{listData.length}}条</text></view><!-- 状态栏的右侧 --><view class="todo-header__right"><view class="todo-header__right-item" :class="{'active-tab':activeIndex === 0}" @click="tab(0)">全部</view><view class="todo-header__right-item" :class="{'active-tab':activeIndex === 1}" @click="tab(1)">待办</view><view class="todo-header__right-item" :class="{'active-tab':activeIndex === 2}" @click="tab(2)">已完成</view></view></view><!-- 没有数据的状态 --><view v-if="list.length === 0" class="default"><view class="image-default"><image src="../../static/default.png" mode="aspectFit"></image></view><view class="default-info"><view class="default-info__text">您还没有创建任何待办事项</view><view class="default-info__text">点击下方+号创建一个吧</view></view></view><!-- 内容 --><view v-else class="todo-content"><!-- todo--finish --><view class="todo-list" :class="{'todo--finish':item.checked}" v-for="(item,index) in listData" :key="index" @click="finish(item.id)"><view class="todo-list__checkbox"><view class="checkbox"></view></view><view class="todo-list__content">{{item.content}}</view></view></view><!-- 创建按钮 --><view class="create-todo" @click="create"><text class="iconfont icon-jia" :class="{'create-todo-active':textShow}"></text></view><!-- 输入框 --><view v-if="active" class="create-content" :class="{'create--show':textShow}"><view class="create-content-box"><!-- input 输入 --><view class="create-input"><input type="text" v-model="value" placeholder="请输入您要创建的todo" /></view><!-- 发布按钮 --><view class="create-button" @click="add">创建</view></view></view></view>
</template><script>export default {data() {return {value: '',list: [],active: false,activeIndex: 0,text: '全部',textShow: false}},onLoad() {},computed: {listData() {let list = JSON.parse(JSON.stringify(this.list))let newList = []// 点击 全部if (this.activeIndex === 0) {this.text = '全部'return list}// 点击 待办事项if (this.activeIndex === 1) {// checked = falselist.forEach((item) => {if (!item.checked) {newList.push(item)}})this.text = '待办'return newList}// 点击 已完成if (this.activeIndex === 2) {// checked = turelist.forEach((item) => {if (item.checked) {newList.push(item)}})this.text = '已完成'return newList}return []},},methods: {// 打开输入框create() {if (this.active) {this.close()} else {this.open()}},// 打开 动画open() {this.active = truethis.$nextTick(() => {setTimeout(() => {this.textShow = true}, 50)})},// 关闭动画close() {this.textShow = falsethis.$nextTick(()=>{setTimeout(() => {this.active = false}, 350)})},// 发布add() {console.log(this.value);if (this.value === '') {uni.showToast({title: "请输入内容",icon: 'none'})return}this.list.unshift({id: 'id' + new Date().getTime(),content: this.value,checked: false})this.value = ''this.close()},// 点击列表触发finish(id) {let index = this.list.findIndex((item) => item.id === id)console.log('我被点击了', this.list[index]);this.list[index].checked = !this.list[index].checked},tab(index) {this.activeIndex = index}}}
</script><style>@import '../../common/icon.css';.todo-header {position: fixed;top: 0;left: 0;display: flex;align-items: center;padding: 0 15px;font-size: 12px;color: #333333;width: 100%;height: 45px;box-sizing: border-box;box-shadow: -1px 1px 5px 0 rgba(0, 0, 0, 0.1);background: #FFFFFF;z-index: 10;}.todo-header__left {width: 100%;}.active-text {font-size: 14px;color: #279abf;padding-right: 10px;}.todo-header__right {flex-shrink: 0;display: flex;}.todo-header__right-item {padding: 0 5px;}.active-tab {color: #279abf;}.todo-content {position: relative;padding-top: 50px;padding-bottom: 100px;}.todo-list {position: relative;display: flex;align-items: center;padding: 15px;margin: 15px;color: #0c3854;font-size: 14px;border-radius: 10px;background: #cfebfd;box-shadow: -1px 1px 5px 1px rgba(0, 0, 0, 0.1), -1px 2px 1px 0 rgba(255, 255, 255) inset;overflow: hidden;}.todo-list:after {position: absolute;content: '';top: 0;bottom: 0;left: 0;width: 5px;background: #91d1e8;}.todo-list__checkbox {padding-right: 15px;}.checkbox {width: 20px;height: 20px;border-radius: 50%;background: #FFFFFF;box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1);}.todo--finish .checkbox {position: relative;background: #eee;}.todo--finish .checkbox:after {content: '';position: absolute;width: 10px;height: 10px;top: 0;left: 0;right: 0;bottom: 0;margin: auto;border-radius: 50%;background: #CFEBFD;box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.2) inset;}.todo--finish .todo-list__content {color: #999999;}.todo--finish.todo-list:before {content: '';position: absolute;top: 0;bottom: 0;left: 40px;right: 10px;height: 2px;margin: auto 0;background: #bdcdd8;}.todo--finish.todo-list:after {background: #cccccc;}.create-todo {display: flex;justify-content: center;align-items: center;position: fixed;bottom: 20px;left: 0;right: 0;margin: 0 auto;width: 50px;height: 50px;border-radius: 50%;background-color: #deeff5;box-shadow: -1px 1px 5px 2px rgba(0, 0, 0, 0.1), -1px 1px 1px 0 rgba(255, 255, 255) inset;}.icon-jia {font-size: 30px;color: #add8e6;}.create-content {position: fixed;bottom: 95px;left: 20px;right: 20px;transition: all 0.3s;opacity: 0;transform: scale(0) translateY(200%)}.create--show {opacity: 1;transform: scale(1) translateY(0);}.create-content-box {display: flex;align-items: center;padding: 0 15px;padding-right: 0;border-radius: 50px;background: #DEEFF5;box-shadow: -1px 1px 5px 2px rgba(0, 0, 0, 0.1), -1px 1px 1px 0 rgba(255, 255, 255) inset;z-index: 2;}.create-input {width: 100%;padding-right: 15px;color: #add8e6;}.create-button {display: flex;justify-content: center;align-items: center;flex-shrink: 0;width: 80px;height: 50px;border-radius: 50px;font-size: 16px;color: #88d4ec;box-shadow: -2px 0px 2px 1px rgba(0, 0, 0, 0.1);}.create-content:after {content: '';position: absolute;right: 0;left: 0;bottom: -8px;margin: 0 auto;width: 20px;height: 20px;background: #DEEFF5;transform: rotate(45deg);box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.1);z-index: -1;}.create-content-box:after {content: '';position: absolute;right: 0;left: 0;bottom: -8px;margin: 0 auto;width: 20px;height: 20px;background: #DEEFF5;transform: rotate(45deg);}.default {padding-top: 100px;}.image-default {display: flex;justify-content: center;}.image-default image {width: 100%;}.default-info {text-align: center;font-size: 14px;color: #CCCCCC;}.icon-jia {transition: transform 0.3s;}.create-todo-active {transform: rotate(135deg);}
</style>

运行结果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/419082.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

android146 360 病毒查杀

<?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas.android.com/apk/res/android"android:layout_width"match_parent"android:layout_height"match_parent"android:orientatio…

24 | 二叉树基础(下):有了如此高效的散列表,为什么还需要二叉树?

这节学习一种特殊的二叉树—二叉查找树。它最大的特点是支持动态数据集合的快速插入、删除、查找操作。但是散列表也是支持这些操作的&#xff0c;并且散列表的这些操作比二叉查找树更高效&#xff0c;时间复杂度是 O(1)。 问题引入 既然有高效的散列表&#xff0c;二叉树的地…

【可持久化线段树】【主席树】[HDU4417]Super Mario

Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. We regard the road to the boss’s castle as a line (the length is n), on ev…

25 | 红黑树(上):为什么工程中都用红黑树这种二叉树?

问题引入 二叉查找树在频繁的动态更新过程中&#xff0c;可能会出现树的高度远大于 log2n 的情况&#xff0c;从而导致各个操作的效率下降。极端情况下&#xff0c;二叉树会退化为链表&#xff0c;时间复杂度会退化到 O(n)。要解决这个复杂度退化的问题&#xff0c;需要设计一…

PHP扩展开发(3)-config.m4

1. 宏命令1.1. dnl 注释 1.2. 扩展的工作方式1.2.1) PHP_ARG_WITH不需要第三方库1.2.2) PHP_ARG_ENABLE依赖第三方库1.3. PHP_REQUIRE_CXX 用于指定这个扩展用到C1.4. PHP_ADD_INCLUDE 指定扩展用到的头文件目录1.5. PHP_CHECK_LIBRARY 指定扩展的PHP_ADD_LIBRARY_WITH_PATH定义…

Rabbitmq如何设置优先级队列?如何限流?如何重试?如何处理幂等性?

优先级队列 方式一&#xff1a;可以通过RabbitMQ管理界面配置队列的优先级属性&#xff0c;如下图的x-max-priority 方式二&#xff1a;代码设置 Map<String,Object> args new HashMap<String,Object>(); args.put("x-max-priority", 10); channel.que…

26 | 红黑树(下):掌握这些技巧,你也可以实现一个红黑树

红黑树的实现&#xff0c;对于基础不太好的同学理解起来困难&#xff08;说的就是我——劝退&#xff09;。学习红黑树的代码实现&#xff0c;对平时做项目开发基本没有太大帮助。对于绝大部分开发工程师来说&#xff0c;这辈子可能都用不着亲手写一个红黑树。 对于我而言&…

【Qt】Qt之进程间通信(Windows消息)【转】

简述 通过上一节的了解&#xff0c;我们可以看出进程通信的方式很多&#xff0c;今天分享下如何利用Windows消息机制来进行不同进程间的通信。 简述效果发送消息 自定义类型与接收窗体发送数据接收消息 设置标题重写nativeEvent效果 发送消息 自定义类型与接收窗体 包含所需库&…

启动nginx服务报错Job for nginx.service failed because the control process exited with error code.

nginx使用service nginx restart报错 启动nginx服务时如果遇到这个错误 Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. 可能原因: 1、配…

几个比58同城交换更好玩的交换玩法

交换&#xff0c;不仅仅是一个经久不息的话题&#xff0c;更是人类自古至今生来就有的行为。货币的产生&#xff0c;为交换带来了便捷&#xff0c;解决了交换的不等价和匹配问题。到今天&#xff0c;社会活动日益丰富&#xff0c;交换赋予了更多的意义和创新。交换的行为&#…

27 | 递归树:如何借助树来求解递归算法的时间复杂度?

目的 借助递归树来分析递归算法的时间复杂度 递归树 递归的思想就是将大问题分解为小问题来求解&#xff0c;然后再将小问题分解为小小问题。这样一层一层地分解&#xff0c;直到问题的数据规模被分解得足够小&#xff0c;不用继续递归分解为止。 如果我们把这个一层一层的…

阿里云IE测试地址

http://ali-aegis.aliyun.com/noPermission.htm 转载于:https://www.cnblogs.com/yexiangwang/p/5163780.html