this-pointer 相关问题


JavaScript 将指针事件从无设置为自动

我需要一种方法来覆盖设置为pointer-events:none 的元素。我已经尝试过一些事情,但它似乎无法控制此设置下的元素。 const meinEl...


Vue.js v-for 不渲染图像

我正在尝试使用 v-for 渲染四个图像,范围为 1 到 4。 v-for="n in 4" :key"n" 但是,使用 'n' 作为 src 的一部分不起作用。为什么? 我正在尝试使用 v-for 渲染四个图像,范围为 1 到 4。 v-for="n in 4" :key"n" 但是,使用 'n' 作为 src 的一部分不起作用。为什么? <div v-for="n in 4" :key="n"> <img :src="`../assets/images/image-product-${n}-thumbnail.jpg`" class="rounded-xl h-16 w-16 hover:cursor-pointer" /> </div> 尝试使用“key”代替“n”,将“n”转换为字符串...没有成功 如果我像这样硬编码,它会起作用 <img src="../assets/images/image-product-1-thumbnail.jpg" class="rounded-xl h-16 w-16 hover:cursor-pointer" /> 如果您有可用的全局别名(@),我建议您使用它。 因为使用相对路径可以在本地工作,但是当项目编译(构建)时,相关路径可能会被破坏。 使用动态 src 路径时,您可以在加载之前需要它。 使用别名,您可以执行以下操作: :src="`require(@/assets/images/image-product-${n}-thumbnail.jpg`)"


禁用按钮时的角度显示工具提示

<button [disabled]="(!dataConceptSummmaryFlag || dataConceptSummmaryFlag === false) && (!selectedLOBFlag || selectedLOBFlag === false) && (!adsListFlag || adsListFlag === false)" class="lmn-btn lmn-btn-primary" aria-label="Update" (click)="updateSelectedScopes()" [mtTooltip]="disabledContent" > Update </button> <ng-container *ngIf="(!dataConceptSummmaryFlag || dataConceptSummmaryFlag === false) && (!selectedLOBFlag || selectedLOBFlag === false) && (!adsListFlag || adsListFlag === false)"> <ng-template #disabledContent>No New Scopes Values Selected</ng-template> </ng-container> 如果在该条件下禁用按钮,如何在悬停时显示工具提示文本,并且当我将鼠标悬停在其上时,我会看到红色关闭图标。这是我尝试过的,但没有成功 将此添加到覆盖材质样式的文件中: // this workaround allows for the tooltips to appear on disabled buttons (since mouse events aren't fired for them) button:disabled.mat-mdc-tooltip-trigger { pointer-events: auto !important; // remove the ripple effect on hover > span:first-child { display: none; } } 悬停时它将显示没有波纹背景的工具提示。


如何去除特定元素的 :hover 效果?

首页 &... <div class="menu-bar"> <ul> <li><a href="/Home/index.html"> <i class="fa fa-house"></i>Home</a> </i></li> < ul > </div> <style> .menu-bar ul li a:hover { color: black; transition: all 0.2s; border-inline-end: 2px solid; border-block-end: 2px solid; </style> 我想从 fa fa-house 的 cdn 图标中删除 :hover 效果。 <div class="menu-bar"> <ul> <li> <i class="fa fa-home"></i> <a href="/Home/index.html"> Home </a> </li> </ul> </div> <style> .menu-bar ul li a:hover { color: black; transition: all 0.2s; border-inline-end: 2px solid; border-block-end: 2px solid; } .menu-bar ul li i{ pointer-events: none; } </style> <div class="menu-bar"> <ul> <li><i class="fa fa-house"></i><a href="/Home/index.html"> Home</a> </i></li> <ul > 只需从 <i> 标签中取出 <a> 元素(图标)即可。 你可以试试这个:- <div class="menu-bar"> <ul> <li><i class="fa fa-house"><a href="/Home/index.html"> </i>Home</a> </i></li> </ul> </div> <style> .menu-bar ul li a:hover { color: black; transition: all 0.2s; border-inline-end: 2px solid; border-block-end: 2px solid; } </style>


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>


如何在声音播放时使图像改变风格或模糊并在声音结束时恢复到原始状态?

看这个简单的代码 音频{显示:无;} 图像{ 宽度:25px; 内容:url(mybutton.png); } 图像:悬停{ 光标:指针; } 功能...</desc> <question vote="-1"> <p>看这个简单的代码</p> <pre><code>&lt;head&gt; &lt;style&gt; audio { display:none;} img { width: 25px; content:url(mybutton.png); } img:hover { cursor: pointer; } &lt;/style&gt; &lt;script&gt; function playSound (mysound) { let theSound = new Audio(mysound); theSound.play(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;img onclick=&#34;playSound(&#39;ch.m4a&#39;)&#34; /&gt; &lt;/body&gt; </code></pre> <p><strong>我想要一个非常简单的CSS或JavaScript代码</strong>可以做到这些:</p> <p>-单击图像时,它会改变样式或变得模糊或更改为另一张图像。然后,声音开始播放。</p> <p>-当声音停止播放时,图像变回原来的状态。</p> <p><strong>我们可以使用非常简单的代码来做到这一点吗?</strong></p> </question> <answer tick="false" vote="0"> <p>您可以向音频添加事件侦听器并在其中应用 css 更改</p> <pre><code>function playSound (mysound) { let theSound = new Audio(mysound); theSound.addEventListener(&#39;ended&#39;, function() { alert(&#39;Audio finished playing!&#39;); }); theSound.play(); } </code></pre> </answer> </body></html>


如何在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 如果您还有任何疑问,请告诉我。


在 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(); }


如何使用 Bootstrap 5 禁用自定义范围而不更改样式?

我有范围: 我有范围: <!DOCTYPE html> <html lang="en"> <head> <!-- Bootstrap --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> </head> <body> <div class="container mb-4 col-sm-5"> <input type="range" class="custom-range" min="0" max="10" value="10" id="range-input" style="width: 100%"> </div> </body> </html> 我想禁用它(它应该仍然看起来一样,但用户不能再与它交互),但是不改变样式。例如: 图中,顶部的启用,底部的禁用;我想禁用它,同时保持顶级范围的样式。 我尝试手动重新创建原始样式,但没有成功: <!DOCTYPE html> <html lang="en"> <head> <!-- Bootstrap --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous" /> <style> input[type=range]:disabled { background-color: blue; color: blue; background: blue; } </style> </head> <body> <div class="container mb-4 col-sm-5"> <input type="range" class="custom-range" min="0" max="10" value="10" id="range-input" style="width: 100%" disabled> </div> </body> </html> 除此之外,我在研究中找不到任何其他可能的解决方案。 您实际上需要“如何”禁用它? 设置 pointer-events: none 并添加 tabindex="-1",你会得到一个看起来仍然相同的元素,但用户无法再与之交互(至少通过鼠标单击/点击,并且他们无法通过键盘将其聚焦)控制其中之一 - 不确定是否还有其他什么?) 由于没有设置 name 属性,该字段不会成为表单提交数据集的一部分 - 如果在您的实际用例中有所不同,您也可以删除(并重新设置)名称,当您可以打开和关闭 tabindex。


为什么我的全景切换按钮不起作用?

我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户观看 360 度全景图时,按钮不应旋转。 我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户查看 360 度全景图时,按钮不应旋转。 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>panoramas</title> <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script> <style> #switchButton { cursor: pointer; } </style> </head> <body> <a-scene> <a-assets> <img id="panorama1" src="1.jpg"> <img id="panorama2" src="2.jpg"> </a-assets> <a-sky id="panorama" src="#panorama1" rotation="0 -130 0"></a-sky> <a-entity id="cameraRig"> <a-camera></a-camera> </a-entity> <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#CCC" id="switchButton"></a-plane> </a-scene> <script> const button = document.querySelector('#switchButton'); let currentPanorama = 1; button.addEventListener('mouseenter', () => { const panorama = document.querySelector('#panorama'); if (currentPanorama === 1) { panorama.setAttribute('src', '#panorama2'); currentPanorama = 2; } else { panorama.setAttribute('src', '#panorama1'); currentPanorama = 1; } }); </script> </body> </html> 我正在尝试制作一个按钮,以便将其绑定到全景图中的特定位置。也就是说,当用户查看 360 度全景图时,按钮不应旋转。 我解决你的问题 您需要做的是添加一个光标来处理 onlcick 事件,这是唯一的方法。 <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1,width=device-width"> <title>A-Frame HTML Shader - Dynamic</title> <script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script> <script src="https://unpkg.com/[email protected]/dist/aframe-html-shader.min.js"></script> <script> let currentPanorama = 1; AFRAME.registerComponent("click-log", { init: function () { this.myFunction = function () { const panorama = document.querySelector('#panorama'); if (currentPanorama === 1) { panorama.setAttribute('src', '#panorama2'); currentPanorama = 2; } else { panorama.setAttribute('src', '#panorama1'); currentPanorama = 1; } }; this.el.addEventListener("click", this.myFunction); }, remove: function () { this.el.removeEventListener("click", this.myFunction); } }); </script> </head> <body> <a-scene update-html> <a-camera> <a-cursor material="color: red"></a-cursor> </a-camera> <a-assets> <img id="panorama1" src="https://l13.alamy.com/360/PWNBM9/testing-new-cameralens-combination-in-my-garden-in-aarhus-denmark-PWNBM9.jpg"> <img id="panorama2" src="https://aframe.io/aframe/examples/boilerplate/panorama/puydesancy.jpg"> </a-assets> <a-sky id="panorama" src="#panorama1" rotation="0 -130 0"></a-sky> <a-entity id="cameraRig"> <a-camera></a-camera> </a-entity> <a-plane click-log position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#CCC" id="switchButton"></a-plane> </a-scene> </body> </html>


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.