微信小程序實現左滑刪除

一、效果

二、代碼

? 實現思路使用的是官方提供的

movable-area:注意點,需要設置其高度,否則會出現列表內容重疊的現象。由于movable-view需要向右移動,左滑的時候給刪除控件展示的空間,故?movable-area 需要左移 left: -120rpx;,movable-view右移left: 120rpx;。 通過 width: calc(100% - 120rpx);左劃的距離。

.moveArea {
? display: flex;
? flex-direction: row;
? width: calc(100% + 120rpx);
? justify-content: center;
? left: -120rpx;
? height: 188rpx;
}
?

movable-view

.movableView {
? display: flex;
? flex-direction: row;
? width: calc(100% - 120rpx);
? z-index: 1001;
? left: 120rpx;
}


Page({/*** 頁面的初始數據*/data: {pushedData:[{messageTitle:'餅干',messageContent:'餅干愛吃'}],//已推送數據},/*** 生命周期函數--監聽頁面加載*/onLoad() {},/*** 生命周期函數--監聽頁面初次渲染完成*/onReady() {},/*** 生命周期函數--監聽頁面顯示*/onShow() {},/*** 生命周期函數--監聽頁面隱藏*/onHide() {},/*** 生命周期函數--監聽頁面卸載*/onUnload() {},/*** 頁面相關事件處理函數--監聽用戶下拉動作*/onPullDownRefresh() {},/*** 頁面上拉觸底事件的處理函數*/onReachBottom() {},/*** 用戶點擊右上角分享*/onShareAppMessage() {},// 退出頁面logout:function(){wx.navigateBack({})},})

xml代碼

<!--pakage_kindness_remind/pages/kindess_msg_remind/kindness_msg_remind_pg.wxml-->
<!-- head -->
<view class="title_search"><view class="seeck_md"><!-- 返回 --><view class="logout" bindtap="logout"><image class="logout_ic" src="/images/msg/return_back.png"></image><text class="logout_txt">返回</text></view><!--內容模板--><view class="msg_title_center"><view class="msg" bindtap="open_msg"><text class="msg_txt">數據中心</text></view></view></view><view class="logout"><image class="logout_ic"></image><text class="logout_txt"></text></view>
</view><!-- body -->
<scroll-view class='scbg' scroll-y='true'><block wx:for="{{pushedData}}" wx:key="id" wx:for-item="itemName" wx:for-index="id"><!-- 子item父布局 --><view class="item_parent"><!-- 日期 4月5日 周二 8:00 --><view class="date" wx:if="{{id==0}}">{{itemName.pushTime}} </view><!--  --><movable-area class="moveArea"><movable-view class="movableView" direction="horizontal" inertia="{{true}}" out-of-bounds="{{true}}"><view style="display: flex;flex-direction: row;width: 100%;height: 100%;"><view class="box_item"><!--head布局--><view class="head_layout"><!-- itemhead左邊模塊  天氣提醒--><view class="head_title">{{itemName.messageTitle}}</view></view><!--body布局--><view class="body_layout">{{itemName.messageContent}}</view></view></view></movable-view> <view class="itemDelet">刪除</view></movable-area></view></block></scroll-view>

css代碼

/* pakage_kindness_remind/pages/kindess_msg_remind/kindness_msg_remind_pg.wxss */Page {background: #f0f0f0;height: 100%;position: fixed;
}/* 頭部搜索 */
/* 搜索標題 */
.title_search {background: linear-gradient(to right, #0455a7, #62c8ec);height: 170rpx;width: 100%;display: flex;flex-direction: row;align-items: flex-end;justify-content: flex-start;
}.seeck_md {display: flex;flex-direction: row;width: 100%;justify-content: flex-start;align-items: flex-end;
}/* 消息 */
.msg {width: 180rpx;height: 90rpx;display: flex;flex-direction: column;justify-content: center;align-items: center;margin-right: 0rpx;margin-left: 30rpx;
}.msg_title_center {width: 100%;display: flex;flex-direction: row;justify-content: center;
}.msg_txt {font-size: 36rpx;height: 80rpx;width: 160rpx;margin-bottom: 20rpx;align-items: center;color: #fff;display: flex;justify-content: center;
}/* 返回 */
.logout {width: 100rpx;height: 90rpx;display: flex;flex-direction: column;justify-content: center;align-items: center;margin-right: 20rpx;margin-left: 30rpx;
}.logout_ic {height: 44rpx;width: 48rpx;margin-right: 2rpx;
}.logout_txt {font-size: 24rpx;height: 40rpx;width: 60rpx;margin-bottom: 10rpx;align-items: flex-start;color: #fff;display: flex;justify-content: flex-start;
}/* 搜索標題 */
/* 頭部搜索  *//* body */
.scbg {background-color: #f0f0f0;width: 100%;height: calc(100vh - 180rpx);left: 0rpx;right: 0rpx;top: 0rpx;padding-bottom: 120rpx;
}/* item條目布局 */
/* item父布局 */
.item_parent {margin-top: 20rpx;
}.date {display: flex;align-items: center;justify-content: center;color: #999999;font-size: 28rpx;margin-bottom: 10rpx;
}/* item盒子 */
.box_item {background-color: #fff;margin-left: 25rpx;margin-right: 25rpx;border-radius: 20rpx;flex-direction: column;width: 100%;height: 160rpx;display: flex;
}/* item模塊時間 *//* item上部分布局 */
.head_layout {height: 60rpx;border-radius: 20rpx;margin-right: 20rpx;display: flex;flex-direction: row;justify-content: space-between;align-items: center;
}/* 標題 */
.head_title {width: 160rpx;display: flex;align-items: center;justify-content: flex-start;margin-left: 20rpx;color: #06c8ad;font-size: 28rpx;font-weight: 800;
}/* item下部份分布局 */
.body_layout {background-color: #fff;padding-bottom: 20rpx;border-radius: 20rpx;margin-bottom: 16rpx;align-items: center;margin-left: 20rpx;margin-top: 10rpx;margin-right: 10rpx;font-size: 28rpx;color: #999999;
}/* 滑動刪除移動模塊 */
.moveArea {display: flex;flex-direction: row;width: calc(100% + 120rpx);justify-content: center;left: -120rpx;height: 188rpx;
}/* 滑動刪除模塊 */
.movableView {display: flex;flex-direction: row;width: calc(100% - 120rpx);z-index: 1001;left: 120rpx;
}/* item刪除 */
.itemDelet {position: absolute;right: 30rpx;line-height: 160rpx;background-color: #62c8ec;margin-top: 0rpx;margin-right: 6rpx;border-bottom-right-radius: 20rpx;border-top-right-radius: 20rpx;width: 120rpx;text-align: right;padding-right: 20rpx;color: #fff;
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/38373.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/38373.shtml
英文地址,請注明出處:http://en.pswp.cn/news/38373.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Android Gradle Plug-in(AGP ) 的對應關系

AGP 和 Gradle 版本的對應關系 Android Gradle 插件版本說明 | Android 開發者 | Android Developers 插件版本所需的最低 Gradle 版本8.18.08.08.07.47.57.37.47.27.3.37.17.27.07.04.2.06.7.1 舊版 插件版本所需的 Gradle 版本4.1.06.54.0.06.1.13.6.0 - 3.6.45.6.4…

sqlloader學習筆記

INFILE的用法 1&#xff09;模糊導入多個數據的文件。 可以在文件名中使用通配符。 星號 &#xff08;*&#xff09; 表示復數字符&#xff0c;問號 &#xff08;&#xff1f;&#xff09; 表示單個字符。 INFILE emp*.dat INFILE m?emp.dat 2&#xff09;如果不需要導入數據…

jQuery EasyUI datagrid 無記錄時,增加“暫無數據“提示

我們只需要在onLoadSuccess中添加如下代碼&#xff1a; if (data.total 0) {var body $(this).data().datagrid.dc.body2;body.find(table tbody).append(<tr><td width" body.width() " style"height: 35px; text-align: center;"><h…

C語言學習之封裝自定義函數,實現atoi函數功能

實例要求&#xff1a;atoi函數的功能是把字符串轉成整型數值并輸出&#xff1b;把字符串"123456"轉換成數值123456 &#xff0c;并返回數值&#xff1b;函數名&#xff1a; int myatoi(char *str);實例分析&#xff1a; 1.自定義的封裝函數類型是整型&#xff0c;…

在阿里云Linux服務器上部署MySQL數據庫流程

阿里云百科分享在阿里云Linux服務器上部署MySQL數據庫流程&#xff0c;MySQL是一個關系型數據庫管理系統&#xff0c;常用于LAMP和LNMP等網站場景中。本教程介紹如何在Linux系統ECS實例上安裝、配置以及遠程訪問MySQL數據庫。 目錄 背景信息 Alibaba Cloud Linux 2/3、CentO…

上傳excel文件

文件上傳&#xff0c;其實就是用el-upload組件來實現上傳&#xff0c;只是換了樣式&#xff0c;和圖片上傳一樣 <el-form-item label"選擇文件"><el-input placeholder"請選擇文件" v-model"form.file" disabled style"width: 45…

java 使用log4j顯示到界面和文件 并格式化

1.下載log4j jar包https://dlcdn.apache.org/logging/log4j/2.20.0/apache-log4j-2.20.0-bin.zip 2. 我只要到核心包 &#xff0c;看需要 sources是源碼包&#xff0c;可以看到說明。在IDEA里先加入class jar后&#xff0c;再雙擊這個class jar包或或右鍵選Navigate ,Add ,…

android.system.ErrnoException: open failed: EPERM (Operation not permitted)

android 10(Q)開始增加了沙盒機制&#xff0c;不能直接把文件保存到/sdcard目錄下&#xff0c;只能保存到APP專屬目錄下&#xff1b;AndroidManifest.xml在標簽下增加屬性【android:requestLegacyExternalStorage“true”】可以暫時保存到/sdcard路徑下&#xff0c;但是Android…

Revit SDK 介紹:PanelSchedule 配電盤明細表

前言 這個例子介紹 Revit 的配電盤明細表&#xff0c;PanelSchedule。Revit 的電器專業在國內用的并不是十分廣泛&#xff0c;但從功能上來說還是比較完整的。 內容 這個例子里有三個命令&#xff1a; PanelScheduleExport - 導出配電盤明細表InstanceViewCreation - 創建配…

【0基礎學爬蟲】爬蟲基礎之網絡請求庫的使用

大數據時代&#xff0c;各行各業對數據采集的需求日益增多&#xff0c;網絡爬蟲的運用也更為廣泛&#xff0c;越來越多的人開始學習網絡爬蟲這項技術&#xff0c;K哥爬蟲此前已經推出不少爬蟲進階、逆向相關文章&#xff0c;為實現從易到難全方位覆蓋&#xff0c;特設【0基礎學…

【Visual Studio Code】--- Win11 C盤爆滿 修改 Code 插件數據和緩存的保存路徑

Win11 C盤爆滿 修改 Code 插件數據和緩存的保存路徑 一、概述二、修改 Code 插件數據和緩存的保存路徑 一、概述 一個好的文章能夠幫助開發者完成更便捷、更快速的開發。書山有路勤為徑&#xff0c;學海無涯苦作舟。我是秋知葉i、期望每一個閱讀了我的文章的開發者都能夠有所成…

領航優配:EFT交易是什么意思?

EFT買賣是一種電子資金搬運買賣方法&#xff0c;EFT代表電子資金搬運&#xff0c;將現金從一個銀行賬戶搬運到另一個銀行賬戶。盡管這種買賣方法已經存在了幾十年&#xff0c;但隨著技能的開展&#xff0c;越來越多的人開始使用它。 從技能視點&#xff0c;EFT買賣是經過計算機…

【C語言】memset()函數

一.memset()函數簡介 我們先來看一下cplusplus.com - The C Resources Network網站上memset()函數的基本信息&#xff1a; 1.函數功能 memset()函數的功能是:將一塊內存空間的每個字節都設置為指定的值。 這個函數通常用于初始化一個內存空間&#xff0c;或者清空一個內存空間…

elementui form組件出現英文提示

今天讓解決一個bug&#xff0c;是表單組件提示詞會出現英文。 問題情景如下&#xff1a; 有時會出現中文&#xff0c;有時會出現英文。 解決方法&#xff1a; 經查看&#xff0c;代碼采用的是elementui的form組件&#xff0c;在el-form-item中使用了required屬性&#xff0c;同…

html的語義化

說說對 html 語義化的理解 去掉或者丟失樣式的時候能夠讓頁面呈現出清晰的結構有利于 SEO&#xff1a;和搜索引擎建立良好溝通&#xff0c;有助于爬蟲抓取更多的有效信息&#xff1a;爬蟲依賴于標簽來確定上下文和各個關鍵字的權重&#xff1b;方便其他設備解析&#xff08;如屏…

Fiddler

基礎 Fiddler 相當于一個 “代理”,瀏覽器訪問瀏覽器頁面時&#xff0c;就會把HTTP請求先發給Fiddler&#xff0c;Fiddler 再把請求轉發給瀏覽器的服務器&#xff0c;當瀏覽器服務器返回數據時&#xff0c;Fiddler拿到返回數據&#xff0c;再把數據交給瀏覽器。 主界面 刪除…

Github上git lfs oid sha256文件無法下載的解決方案

問題&#xff1a;github上sha文件無法下載&文件超出限制 當我克隆Github上的一個庫時&#xff0c;其中有一個包的內容格式如下&#xff1a; version https://git-lfs.github.com/spec/v1 oid sha256:一堆數字和字母 size 一堆數字 這堆東西類似百度網盤的下載鏈接和密碼&a…

設計HTML5表單

HTML5基于Web Forms 2.0標準對HTML4表單進行全面升級&#xff0c;在保持簡便、易用的基礎上&#xff0c;新增了很多控件和屬性&#xff0c;從而減輕了開發人員的負擔。表單為訪問者提供了與網站進行互動的途徑&#xff0c;完整的表單一般由控件和腳本兩部分組成。 1、認識HTML…

LeetCode150道面試經典題-- 匯總區間(簡單)

1.題目 給定一個 無重復元素 的 有序 整數數組 nums 。 返回 恰好覆蓋數組中所有數字 的 最小有序 區間范圍列表 。也就是說&#xff0c;nums 的每個元素都恰好被某個區間范圍所覆蓋&#xff0c;并且不存在屬于某個范圍但不屬于 nums 的數字 x 。 列表中的每個區間范圍 [a,…

紅黑樹(RBTree)

紅黑樹 1. 紅黑樹的概念2. 紅黑樹的性質3. 紅黑樹節點的定義4. 紅黑樹的插入操作5. 紅黑樹與AVL樹的比較 1. 紅黑樹的概念 紅黑樹是一種自平衡二叉查找樹&#xff0c;是在計算機科學中用到的一種數據結構&#xff0c;典型用途是實現關聯數組。它在1972年由魯道夫貝爾發明&…