py-datatable 相关问题


属性错误:模块“Project1”没有属性“py”

运行代码时 导入项目1、项目2、项目3 从线程导入线程 线程(目标=Project1.py).start() 线程(目标=Project2.py).start() 线程(目标=Project3.py).start() 到...


如何导入本地安装的库?

我已经使用以下命令安装了我的库: 点安装。 这是目录结构: └────模块1 ├────__init__.py └────mod_1.py └────模块2 ├────__init__.py └────mod_2...


鼠标悬停在饼图窗口中形式c#

如何在饼图中显示数量,当我将光标悬停在饼图上时,我有此代码,但它不起作用。我是这个 c# 代码的新手 DataTable dt = new DataTable(); 合作...


Python如何模拟cmd用户输入

我使用的是Windows 10。 我有一个包含 getpass.getpass() 的文件(1.py),我想使用 python 自动输入密码。 我尝试了 subprocess.Popen(['py', '1.py'], stdin=subprocess...


在 Angular 中打开模态时出现ExpressionChangedAfterItHasBeenCheckedError

` `<ngx-datatable-column *ngIf="search_type ==='booking'" [width]="50" [sortable]="false" [canAutoResize]="false" [draggable]="false" [resizeable]="false"> <ng-template ngx-datatable-cell-template let-row="row" let-value="value"> <span class="fa fa-user-plus font-medium-3 text-primary cursor-pointer pl-1" (click)="onUpdateBookingLinguist(row)"></span> </ng-template> </ngx-datatable-column>` 上面是我的html代码,下面是我的ts代码 ` onUpdateBookingLinguist(linguist: Linguist) { const modalRef = this.modalService.open(ScheduledBookingModalComponent, { size: 'lg' }); modalRef.componentInstance.linguist_other_bookings = linguist['scheduled_booking']; modalRef.result.then((result) => { if (!result) { return; } this.cdr.detectChanges(); }).catch((e) => { }); this.cdr.detectChanges(); }` 我试图从 ngx-datatable-column 打开模式,但收到此错误 错误错误:NG0100:ExpressionChangedAfterItHasBeenCheckedError:表达式在检查后已更改。上一个值:“datatable-body-cell sort-active active”。当前值:'datatable-body-cell sort-active'.. 欲了解更多信息,请访问 https://angular.io/errors/NG0100 我尝试使用 ChangeDetectorRef.detectChanges() 手动触发更改检测,但仍然收到错误。 当您修改 Angular 在其更改检测周期期间也尝试检查或更新的属性时,通常会出现此错误。 因此您可以使用 ChangeDetectorRef 在特定情况下手动触发更改检测。通过从 ChangeDetectorRef 调用 detectorChanges(),您可以手动指示 Angular 对该组件及其子组件重新运行更改检测,从而可能解决问题 这是如何在组件中使用ChangeDetectorRef 的示例 构造函数(私有 cdr:ChangeDetectorRef){} ngAfterContentChecked() { this.cdr.detectChanges(); }


使用 Azure Function 运行时和 pytest 'ModuleNotFoundError:没有名为...的模块'时出现导入问题

我的项目结构如下所示: 回购/ |--模型/api |--function/function_app.py |--函数/工具.py |--函数/__init__.py |--测试/test_function_app.py ...


VIM YouCompleteMe 搜索 py 库时出错

我在 VIM 中安装 YCM 并收到此错误: 正在搜索 Python 3.8 库...错误:/usr/include/python3.8 中缺少 Python 标头 我尝试过 py 3.8 3.7 和 3.9,也是一样的...


Laravel 类“数据表”未找到错误?

我正在开发一个应用程序,从 Mysql 数据库检索数据并使用 Laravel 和 Datatable 显示它,我不断收到此错误: “未找到‘数据表’类” 我尝试了不同的版本...


在代码隐藏中绑定到 DataTable 时,DataGrid 会部分更新

我有一个 WPF 窗口,其中有一个 DataGrid 作为其子窗口之一。 DataGrid 中的列数仅在运行时确定。以下是我的 window.xaml 文件中 DataGrid 的代码: <


从Django检索数据通过Datatable选择Option

我有一个问题,在渲染数据表或触发后,我无法将 payrolled_list 中的 Django 数据调用到选择选项中。我只想将 Django 中的数据反映到选择选项,但我


Alpine.js 和 jQuery DataTables,x-on:在表内触发时单击功能不全

我的 Laravel 和 Alpine.js 刀片页面中有此表。 名字 我的 Laravel 和 Alpine.js 刀片页面中有此表。 <table id="projects-table"> <thead> <tr> <th>name</th> <th>actions</th> </tr> </thead> <tbody> @foreach($projects as $project) <tr> <td>{{ $project->name }}</td> <td><button x-data="{}" x-on:click="$dispatch('open-modal', 'edit-project')">edit</button></td> </tr> @endforeach </tbody> </table> 有了它,我有了这个 JavaScript 代码,可以将其转换为 jQuery DataTable document.addEventListener('DOMContentLoaded', function () { new DataTable('#projects-table'); }); 现在发生的情况是,当我单击 button 内的 td 时,我的模式不会触发 当表不是 DataTable 时,一切正常。 基本上发生了什么(可能),当 jQuery 操作元素时,@click 事件不会触发。有任何已知的修复方法吗?感谢所有帮助。 解决方案是将表包含在由 Alpine 控制的标签中,并在 Alpine 启动后初始化 DataTable: <div x-data> <table id="projects-table"> <!-- ..... --> </table> </div> <script> document.addEventListener('alpine:init', () => { new DataTable('#projects-table') }); </script> 通过这种方式,Alpine 可以检测到 DOM 何时被 DataTables 更改,然后重建他的引用。 否则,在您的具体情况下,您可以使用 vanilla JS 发送自定义事件并保持其他内容不变: <!-- ..... --> <td> <button onclick="window.dispatchEvent(new CustomEvent('open-modal', { detail: 'edit-project' }))"> Edit </button> </td> <!-- ..... --> <!-- Simple example for the modal triggering --> <div x-data="{isOpen: false}" x-show="isOpen" @open-modal.window="isOpen = true"> I'm open! <div>


Primereact Datatable 服务器端带过滤器分页?

我正在使用 primereact,我想提高表的性能,所以我想将其设置为服务器端分页,但我遇到了一些问题,服务器端分页可以使用此代码,但是


如何将 .py 文件上传到 SharePoint 并按计划运行脚本?

我有一个Python脚本,可以从网站提取数据,我想定期运行它,例如每天12:00。如何将此 .py 文件保存在 SharePoint 上的某个位置并将其设置为...


从与主文件不同的文件夹中使用 Hydra 实例化对象

我的文件夹结构如下所示: Hydra_配置 数据集 数据集配置.yaml 配置.yaml 源代码 数据集.py 回购协议 主要.py 在main.py中,我可以设置Hydra装饰的config_path...


使用Pytest时将主数据库更改为Test

帮我解决问题 这是我的设置.py: 数据库= { “默认”: { "ENGINE": "django.db.backends.mysql", “名称”:ENV.MYSQL_DSN....


ClosedXML 导出数据网格到 Excel 仅 10 行

我有一个包含 60 行数据的数据网格和一个将其导入 Excel 的按钮: 我有一个包含 60 行数据的数据网格和一个将其导入 Excel 的按钮: <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Source}" CanUserAddRows="False" HeadersVisibility="All" Name="dgDisplay"> <DataGrid.Columns> <DataGridTextColumn Header="Day" Binding="{Binding Day}"/> <DataGridTextColumn Header="Data" Binding="{Binding Data}"/> </DataGrid.Columns> </DataGrid> <Button Command="{Binding SaveDataGridToExcelCommand}" CommandParameter="{Binding ElementName=dgDisplay}"/> 其中 Day 和 Data 只是一些随机生成的 int 数据。 我的代码使用 ClosedXML 将数据从中导出到 Excel,它使用 MainWindowViewModel: ObservableObject 调用 MVVM.Toolkit。 [RelayCommand] public void SaveDataGridToExcel(DataGrid dataGrid) { DataTable dt = new DataTable(); foreach (DataGridColumn column in dataGrid.Columns) { dt.Columns.Add(column.Header.ToString()); } foreach (var item in dataGrid.Items) { DataRow dr = dt.NewRow(); bool rowHasData = false; for (int i = 0; i < dataGrid.Columns.Count; i++) { var cellContent = dataGrid.Columns[i].GetCellContent(item); if (cellContent is TextBlock textBlock) { //check if row empty, dont add this row.I add it on purpose to check //if the datagrid recognite the rest 50 rows not have data. It actually //dont save those data dr[i] = textBlock.Text; if (!string.IsNullOrEmpty(textBlock.Text)) { rowHasData = true; } } } if (rowHasData) { dt.Rows.Add(dr); } } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { using (XLWorkbook wb = new XLWorkbook()) { wb.Worksheets.Add(dt, "Sheet1"); wb.SaveAs(saveFileDialog.FileName); } } } 但是保存的60行结果只显示了10行数据,其余50行都是空的。如果疑问为什么不使用Microsoft.Interop.Excel,那是因为该包不适合我的 Excel 版本。我没有在 ClosedXML 中看到任何对此有限制或许可的地方,所以我想知道为什么。如有任何帮助,我们将不胜感激。 在浏览 github 几个小时后,我自己找到了答案。 我没有访问单元格内容,而是直接从 DataGrid 的 ItemsSource 访问数据: public void SaveDataGridToExcel(DataGrid dataGrid) { DataTable dataTable = new DataTable(); foreach (DataGridColumn column in dataGrid.Columns) { dataTable.Columns.Add(column.Header.ToString()); } var itemsSource = dataGrid.ItemsSource as IEnumerable; if (itemsSource != null) { foreach (var item in itemsSource) { var properties = item.GetType().GetProperties(); var row = dataTable.NewRow(); foreach (var property in properties) { row[property.Name] = property.GetValue(item); } dataTable.Rows.Add(row); } } //show dialog... }


(PYGAME) 玩家矩形不动

导入pygame # 初始化 游戏 = 真实 pygame.init() 帧率 = 30 时钟 = pygame.time.Clock() # 屏幕 屏幕 = pygame.display.set_mode((600,800)) 屏幕.填充((0,0,0)) # 玩家 像素 = 300 pY = 40...


Django 如何在 i18n_patterns 中设置默认语言?

设置.py 从 django.utils.translation 导入 ugettext_lazy as _ LANGUAGE_CODE = '嗨' # 激活的语言列表 语言 = ( ('嗨', _('印地语')), ('en', _('英语')), ) urls.py


玩家矩形不移动[重复]

导入pygame # 初始化 游戏 = 真实 pygame.init() 帧率 = 30 时钟 = pygame.time.Clock() # 屏幕 屏幕 = pygame.display.set_mode((600,800)) 屏幕.填充((0,0,0)) # 玩家 像素 = 300 pY = 40...


如何在重置密码(PasswordResetView)django中禁用自动发送电子邮件

这是我的观点.py 类 CustomPasswordResetView(PasswordResetView): template_name = '用户/password_reset_form.html' success_url = reverse_lazy('密码重置') def form_valid(自我, 形式): ...


如何在React Prime DataTable中添加超链接?

我有一个数据表,我正在使用 React prime 库, 我的要求是在一个特定列中添加一个链接。 我有一个数据表,我正在使用 React prime 库, 我的要求是在一个特定列中添加一个链接。 <DataTable paginator rows={tableRowPage} value={products} tableStyle={{ minWidth: "30rem" }} ><Column key={field} field={field} header={header} style={{ width: "25%" }} /> </DataTable> 我需要特定单元格中的超链接 我在数据表中遇到了同样的问题,不幸的是,根据我的研究,他们似乎不提供对此的支持。 但是,我已经设法通过这种方式解决了这个问题: 数据表添加链接逻辑: <Column field="code" header="Code" body={(rowData) => { return ( <div sx={{ display: "flex", justifyContent: "space-between", alignItems: "center", }} > <div style={{ color: "#3F00FF", textDecoration: "underline", cursor: "pointer", "&:hover": { color: "#23297A", }, }} onClick={() => window.open("www.google.com", "_blank").focus()} > {rowData.code} </div> </div> ); }} ></Column>; 我已经使用 Prime React Column 组件中的 body 渲染了数据。我应用 CSS 将其设置为链接样式,并添加了 onClick 事件以进行重定向。您可以根据您的要求修改逻辑。 完整代码链接:https://codesandbox.io/s/primereact-demo-forked-kqtdvs?file=/src/App.jsx 如果您还有任何疑问,请告诉我。


Discord.py 机器人在应用 cog 后无法检测到命令

这里是main.py和Vige.py文件 这是 main.py 文件 #销货成本 初始扩展名 = [] 对于 os.listdir('./cogs') 中的文件名: if filename.endswith('.py'): 初始扩展.a...


Ngrok“HTTP 错误 404”。找不到所请求的资源

错误图片 我尝试使用“ngrok”执行我的 django-app。添加了 url 到“ALLOWED_HOSTS”和其他需要的变量。我做了“py manage.py runserver”和“ngrok http ...


方法不允许(POST)我被卡住了

我几个小时以来一直在尝试解决这个问题。我似乎看不出导致错误的原因:( 视图.py @要求登录 def create_brand(请求): template_name = "poc/brand_add.html"


ValueError:展开时出现包装循环

Python3 测试用例(文档测试)在我的示例代码中失败。但在 Python2 中同样可以正常工作。 测试.py: 类测试(对象): def __init__(self, a=0): self.a = a def __getat...


Django - PropertyFilterSet - 当属性引用模型时如何过滤属性

给定以下 Django 模型,如何使用 django_property_filter 包过滤模型的属性: # 模型.py 从 django.db 导入模型 类管理器(模型.模型): 名称 = 型号。


zeromq 运行一段时间后失败

我当前运行一个进程以及一个API。这两者需要进行通信,更具体地说是进程的 API。为此,我使用 Zeromq 的 Python 库。我的代码如下: 服务器.py: ...


为什么我无法安装tensorflow?

我确定我使用的是3.6版本,并且我尝试了一切。 这是我尝试过的: py -m pip 安装张量流 错误:找不到满足张量流要求的版本(来自版本:...


如何运行python源文件并显示源代码和输出

我的“hello.py”文件包含: msg =“你好,世界!” 打印(消息) 当我在 shell 中运行它时,我看到 $ python 你好.py 你好世界! $ 但我想 $ python -q [一些选项] hel...


Heroku 在部署时按预期执行collectstatic?

我设置了 Django 来收集静态文件并使用 django-storages 将它们复制到 S3 中,当我显式运行时,这就像一个魅力 heroku运行python管理.py收集静态 不过,我...


即使文件夹位于系统路径中也会出现ModuleNotFoundError

我在尝试导入包时不断收到 ModuleNotFoundError 错误。 我的文件夹结构如下: -系统 - 有 ---元素.py - 程式 ---用户界面 ----svc.py 我必须将element.py导入到svc.py中,...


笔记本无法在同一文件夹中导入模块(Python)

在我的笔记本分析中,我想使用一些用不同脚本(但在同一文件夹中)编写的函数。它看起来像这样: 主文件夹: - 子文件夹 - __init__.py ...


使用在另一个文件中定义的函数中创建的变量

我有两个.py 文件,假设a.py 和b.py。在 a.py 中,我有很多函数,在这些函数中创建变量并将其声明为全局变量: def func1(): 全局x x = 2


使用 Mypy 插件对动态属性创建进行类型检查

我有一个代码库,它使用一种非常奇怪的模式来定义命令行选项。它看起来像这样: # 选项.py 定义组(): o = 选项组() 返回 o, o.define 选项 =


从config中导入参数,如果不存在则先创建config

我有一些全局常量,它们保存在 .py 文件中,并且代码库中的许多不同位置都需要它们: 从重要参数导入 ROOT_DIR、ANOTHER_DIR 这个进口是需要的...


VSCode - 重命名符号会跳过 Python 项目中的测试文件

在我的 Python 项目中,当我使用 VSCode 重命名符号时,更改不会传播到“测试文件”。更具体地说,如果 .py 文件位于名为 test 的目录中或名为 test_...


我转换了.py-->.exe,但代码不起作用

你好,我转换了我的Python文件,它在循环中播放声音,但是当我尝试将它作为exe文件运行时它不起作用。 我的代码: 导入时间 从 Playsound 导入 Playsound def 函数(次数,how_...


如何在不重新启动的情况下更改选择。不和谐.py

我的机器人基于经常更新的数据库。 其中一个团队的机器人提供了课程主题的选择(取自表格)。看起来可行,但是如果对表进行更改


使用单元IsolatedAsyncioTestCase测试fastapi路由时出现“运行时错误:事件循环已关闭”

考虑这个 mcve: 要求.txt: 快速API httpx 发动机 派丹提克[电子邮件] python-bsonjs uvicorn==0.24.0 主要.py: 导入异步 导入单元测试 从输入 import 可选 导入 motor.motor_asyn...


正确的虚拟环境设置以允许 VS Code 格式化 Python 文件(使用 autopep8、Black Formatter 或 Ruff)

在 Visual Studio Code 中,所有 Python 格式化程序扩展都无法格式化我的 .py 文件。消息是“跳过标准库文件”。 我知道 Python 内置了格式化程序...


Selenium 4.16 Python:(没有这样的元素)和(会话信息:chrome=120.0.6099.130);有关此错误的文档)

在此输入我尝试在 Py Charm 上使用 Selenium 4.16,我运行以下代码并收到错误消息: 从硒导入网络驱动程序 从 selenium.webdriver.common.by 导入 驱动程序=网络驱动程序。


如何设置enum将数据库中的值保存为int值、FastAPI和Postgres?

所以我尝试建立一个像前提一样保持价值的系统。 管理员=0 编辑=1 观众 = 2 我尝试让模型用户像这样。 #模型.py 用户类(基础模型): __表名__ =“用户” ...


Python向http请求返回图像

我在 iis 中使用 *.py 的处理程序“c:...\python.exe %s %s”设置 python。然后想要提供像“https://.../getpng.py?no=1”这样的url来将图像流返回到html,如下所示 我在 iis 中使用 *.py 的处理程序“c:...\python.exe %s %s”设置 python。然后想要提供像“https://.../getpng.py?no=1”这样的url来将图像流返回到html,如下所示 <img src="https://.../getpng.py?no=1"> getpng.py 很简单,如下所示。 with open('C:\\inetpub\\wwwroot\\test\\test1.png', 'rb') as f: filecontent = f.read() print('Content-Type: image/png\r\n\r\n') print(filecontent ) 图片路径正确。文件内容正确。但html页面总是显示损坏的图像。 看起来“打印(文件内容)”失败了。有解决这个问题的提示吗? 我尝试了 sys.stdout.write 但这也不起作用。 还尝试了以下方法均无效 print('内容类型:图像/png ' + 文件内容 ) print('内容类型:图像/png {0}'.format(文件内容)) 您可以使用base64在网页上显示图像; import base64 with open('QR.jpg', 'rb') as image_file: base64_bytes = base64.b64encode(image_file.read()) #print(base64_bytes) base64_string = base64_bytes.decode() print(base64_string) # For insert into the img tag. 比进入html: <img src=" data:image/jpeg; data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ.... " alt="QR.jpg" />


ASP.NET MVC 项目模板在移动设备上无法调整为 100%

我不明白为什么 Web .Net MVC 项目上的默认模板没有在移动设备中调整为 100% 宽度。 我在视图上使用数据表: @模型IEnumerable 我不明白为什么 Web .Net MVC 项目上的默认模板没有在移动设备中调整为 100% 宽度。 我在视图上使用数据表: @model IEnumerable<iziConference.Models.EventAttendee> <h2>Participantes.</h2> <br /> <button><a style="text-decoration: none" href='@Url.Action("Create", new { eventId = ViewBag.EventId })'>Criar Participante</a></button> <button id="at-btn-refresh"> Actualizar</button> <input id="eventId" type="hidden" value="@ViewBag.EventId"> <table id="at-attendees-list" cellpadding="10" border="1" class="row-border stripe"> <thead> <tr> <th>ID</th> <th>Tipo</th> <th>Nome</th> <th>Email</th> <th>Estado </th> </tr> </thead> <tbody> @foreach (var item in Model) { <tr id="[email protected]_Id"> <td style="padding: 5px"> @Html.DisplayFor(modelItem => item.Attendee.Id) </td> <td> @Html.DisplayFor(modelItem => item.AttendeeType) </td> <td> @Html.DisplayFor(modelItem => item.Attendee.Name) </td> <td> @Html.DisplayFor(modelItem => item.Attendee.Email) </td> <td> @if (item.IsActive) { <button id="[email protected]_Id" class="at-btn-active-state active" data-attendee-id="@item.Attendee_Id" data-attendee-name="@item.Attendee.Name" data-active-new-state="false" data-show-confirmation-alert="true">Desactivar</button> } else { <button id="[email protected]_Id" class="at-btn-active-state inactive" data-attendee-id="@item.Attendee_Id" data-attendee-name="@item.Attendee.Name" data-active-new-state="true" data-show-confirmation-alert="true">Activar</button> } </td> </tr> } </tbody> </table> 由脚本加载: var _atteendeesList = "at-attendees-list"; $("#" + _atteendeesList).DataTable({ "paging": false, "info": false, "language": { "search": "Pesquisar:", "info": "Participantes inscritos: _PAGES_" } }); 使用默认的_Layout.cshtml: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>izigo Conference - Gestor de Conteúdos</title> <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <meta name="viewport" content="width=device-width" /> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/modernizr") </head> <body> <header> <div class="content-wrapper"> <section id="login"> @Html.Partial(MVC.Account.Views._LoginPartial) </section> <div style="padding: 10px;"> @if (Request.IsAuthenticated) { <nav> <ul id="menu"> <li>@Html.ActionLink("Home", MVC.Home.Index())</li> <li>@Html.ActionLink("Participantes", MVC.Attendee.Index())</li> <li>@Html.ActionLink("Check-in", MVC.Checkin.Index())</li> </ul> </nav> } </div> </div> </header> <div id="body"> @RenderSection("featured", required: false) <section class="content-wrapper main-content clear-fix"> @RenderBody() </section> </div> <footer style="padding-left: 25px;"> <div class="content-wrapper"> <div class="float-left"> <p>&copy; @DateTime.Now.Year - <a href="https://www.izigo.pt/conference" target="_blank">izigo Conference</a> - <i>Powered by</i><a href="https://www.izigo.pt" target="_blank">izigo.pt</a></p> </div> </div> </footer> @Scripts.Render("~/bundles/jquery", "~/bundles/iziconference") @RenderSection("scripts", required: false) </body> </html> 研究了 dataTables 库的选项后,我找到了一个创建响应式解决方案的选项: 我已经包含了响应表结构和columnDefs的选项,以选择哪些选项在移动设备中保持可见: $("#" + _atteendeesList).DataTable({ "responsive": true, "columnDefs": [ { responsivePriority: 1, targets: 0 }, { responsivePriority: 2, targets: -1 } ], "paging": false, "info": false, "language": { "search": "Pesquisar:", "info": "Participantes inscritos: _PAGES_" } }); 我还必须在捆绑包中包含数据表扩展的 js 和 css 响应式库(可在此处下载:https://datatables.net/download/): bundles.Add(new ScriptBundle("~/bundles/iziconference").Include( "~/Content/Scripts/datatables.min.js", "~/Content/Scripts/dataTables.responsive.min.js")); // add-on bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/Styles/datatables.min.css", "~/Content/Styles/responsive.dataTables.min.css"));


Tailwind 和 CSS 动画环偏移缩小

<div class="flex flex-col items-center justify-center rounded-xl bg-[#101638] px-5 pb-8 pt-7"> <div class="relative mb-5 cursor-pointer"> <img class="mx-auto max-w-[90px] rounded-full p-1 ring ring-offset-8 ring-offset-[#101638] hover:ring-offset-0 ring-[#133e8d] md:max-w-[114px]" src="/images/Avatar1.png" alt="Bordered avatar"> <div class="absolute bottom-1 right-2 rounded-full bg-blue-600 px-2 py-1 ring-4 ring-[#0d1129]"> <svg class="svg-inline--fa fa-message-dots text-white" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="message-dots" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path class="" fill="currentColor" d="M0 64C0 28.7 28.7 0 64 0H448c35.3 0 64 28.7 64 64V352c0 35.3-28.7 64-64 64H309.3L185.6 508.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3V416H64c-35.3 0-64-28.7-64-64V64zM128 240a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm128 0a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm160-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"></path> </svg> </div> </div> <div> <h1 class="font-bold">First Name</h1> </div> <div> <h1>Name</h1> </div> <div> <h1 class="text-[#636da8]">Project Mngr</h1> </div> </div> 如何为任何 css/tailwind 解决方案的偏移环的过渡设置动画? 例如,这 2 个缩略图,左边的缩略图悬停在其上,右边的缩略图是初始状态。我希望它在缩略图悬停时有一个缩小的动画,而不是我当前的动画,因为它非常突然 您可以考虑应用包含 transition-property 的 box-shadow CSS 值,例如 transition 或 transition-all Tailwind 类,以及非 0 transition-duration,上述类名也设置了: <script src="https://cdn.tailwindcss.com/3.4.1"></script> <div class="flex flex-col items-center justify-center rounded-xl bg-[#101638] px-5 pb-8 pt-7"> <div class="relative mb-5 cursor-pointer"> <img class="mx-auto max-w-[90px] rounded-full p-1 ring ring-offset-8 ring-offset-[#101638] hover:ring-offset-0 ring-[#133e8d] md:max-w-[114px] transition" src="https://picsum.photos/90/90" alt="Bordered avatar"> <div class="absolute bottom-1 right-2 rounded-full bg-blue-600 px-2 py-1 ring-4 ring-[#0d1129]"> <svg class="svg-inline--fa fa-message-dots text-white" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="message-dots" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path class="" fill="currentColor" d="M0 64C0 28.7 28.7 0 64 0H448c35.3 0 64 28.7 64 64V352c0 35.3-28.7 64-64 64H309.3L185.6 508.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3V416H64c-35.3 0-64-28.7-64-64V64zM128 240a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm128 0a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm160-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"></path> </svg> </div> </div> <div> <h1 class="font-bold">First Name</h1> </div> <div> <h1>Name</h1> </div> <div> <h1 class="text-[#636da8]">Project Mngr</h1> </div> </div> 否则,您可以考虑通过 transition-property: box-shadow Tailwind 类应用 transition-duration: 150ms; 和 transition-[box-shadow](以及其他属性)以仅转换 box-shadow: <script src="https://cdn.tailwindcss.com/3.4.1"></script> <div class="flex flex-col items-center justify-center rounded-xl bg-[#101638] px-5 pb-8 pt-7"> <div class="relative mb-5 cursor-pointer"> <img class="mx-auto max-w-[90px] rounded-full p-1 ring ring-offset-8 ring-offset-[#101638] hover:ring-offset-0 ring-[#133e8d] md:max-w-[114px] transition-[box-shadow]" src="https://picsum.photos/90/90" alt="Bordered avatar"> <div class="absolute bottom-1 right-2 rounded-full bg-blue-600 px-2 py-1 ring-4 ring-[#0d1129]"> <svg class="svg-inline--fa fa-message-dots text-white" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="message-dots" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path class="" fill="currentColor" d="M0 64C0 28.7 28.7 0 64 0H448c35.3 0 64 28.7 64 64V352c0 35.3-28.7 64-64 64H309.3L185.6 508.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3V416H64c-35.3 0-64-28.7-64-64V64zM128 240a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm128 0a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm160-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"></path> </svg> </div> </div> <div> <h1 class="font-bold">First Name</h1> </div> <div> <h1>Name</h1> </div> <div> <h1 class="text-[#636da8]">Project Mngr</h1> </div> </div>


Flatpickr AlpineJS 在危险范围选择上坚持插件

我有一个工作完美的 Flatpickr 日期范围日历,它将日期存储在会话存储中。这是我的代码: 我有一个工作完美的 Flatpickr 日期范围日历,它将日期存储在会话存储中。这是我的代码: <div x-data="{ chosenDates: sessionStorage.getItem('_x_range'), value: [], init() { let picker = flatpickr(this.$refs.picker, { mode: 'range', inline: false, dateFormat: 'm/d/Y', showMonths: 2, }) this.$watch('value', () => picker.setDate(this.value)) }, }" > <div class="flex items-center flex-1 gap-2 overflow-hidden border border-gray-500 rounded-lg"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="ml-4 bi bi-calendar-event-fill" viewBox="0 0 16 16"> <path d="M4 .5a.5.5 0 0 0-1 0V1H2a2 2 0 0 0-2 2v1h16V3a2 2 0 0 0-2-2h-1V.5a.5.5 0 0 0-1 0V1H4zM16 14V5H0v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2m-3.5-7h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5"/> </svg> <input id="rangeValue" :value="chosenDates" placeholder="Add dates" x-ref="picker" type="text" class="p-0 py-4 placeholder-gray-600 border-0 bg-none focus:ring-0 " data-input> </div> </div> 设置项目: function dateRange() { var date = document.getElementById("rangeValue").value; sessionStorage.setItem("_x_range", date); sessionStorage.setItem("start", start); sessionStorage.setItem("end", end); const start = sessionStorage.getItem("start"); } $('#rangeValue').on('focus', ({ currentTarget }) => $(currentTarget).blur()) $("#rangeValue").prop('readonly', false) ``` Receive item: if (sessionStorage.getItem("_x_range") != null) { document.getElementById("chosenRange").innerHTML = sessionStorage.getItem("_x_range"); document.getElementById("rangeValue").value = sessionStorage.getItem("_x_range"); } ``` 如果可能的话,我想学习如何使用 AplineJS 和 Persist 来设置它,以免代码过多而过期。 这可能吗? 这是一个可能的解决方案: <div x-data="{ thePicker: null, chosenDates: $persist([]).using(sessionStorage).as('_x_range'), init() { this.thePicker = flatpickr(this.$refs.picker, { mode: 'range', inline: false, dateFormat: 'm/d/Y', showMonths: 2, defaultDate: this.chosenDates, onChange: (selectedDates) => {this.chosenDates = [...selectedDates];} }); }, }" > <div class="flex items-center flex-1 gap-2 overflow-hidden border border-gray-500 rounded-lg"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="ml-4 bi bi-calendar-event-fill" viewBox="0 0 16 16"> <path d="M4 .5a.5.5 0 0 0-1 0V1H2a2 2 0 0 0-2 2v1h16V3a2 2 0 0 0-2-2h-1V.5a.5.5 0 0 0-1 0V1H4zM16 14V5H0v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2m-3.5-7h1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5"/> </svg> <input type="text" x-ref="picker" placeholder="Add dates" class="p-0 py-4 placeholder-gray-600 border-0 bg-none focus:ring-0" > <span title="Clear" class="text-blue-600 cursor-pointer" @click="thePicker.clear()" > X </span> </div> <div x-text="chosenDates"> </div> </div> 日期范围存储在 Alpine chosenDates 变量中,该变量通过 Persist 进行持久化并初始化为空数组。 当日期选择器初始化时,chosenDates变量用于填充defaultDate参数。 选择日期范围后,flatpicker 会触发 onChage 事件,因此我使用它将新范围复制到 chosenDates 变量中。 我添加了一个 “clear” 按钮以 flatpicker 方式重置输入字段,调用 clear() 方法(这是一个简单的示例),然后我必须将 flatpicker 引用存储在 thePicker 中变量. 我还添加了一个 通过 x-text 显示 choosenDates 的内容


© www.soinside.com 2019 - 2024. All rights reserved.