当前位置: 首页 > news >正文

网站怎么做登录界面2345浏览器下载安装

网站怎么做登录界面,2345浏览器下载安装,dw做框架网站,做网站多少钱啊React:tabs或标签页自定义右击菜单内容,支持内嵌iframe关闭菜单方案 不管是react、vue还是原生js,原理是一样的。 注意如果内嵌iframe情况下,iframe无法使用事件监听,但是可以使用iframe的任何点击行为都会往父级wind…

React:tabs或标签页自定义右击菜单内容,支持内嵌iframe关闭菜单方案

不管是react、vue还是原生js,原理是一样的。
注意如果内嵌iframe情况下,iframe无法使用事件监听,但是可以使用iframe的任何点击行为都会往父级window通信,使用window的message事件监听即可。

场景

前端自定义标签页,一个标签对应一个路由页面,通过切换标签快速切换不同应用或者页面

代码

变量
state = {contextMenuIndex: '', // 右击菜单索引contextMenuPosition: { // 右击菜单定位信息clientX: '',clientY: '',},visiableContextMenu: false, // 右击菜单是否显示};
事件加载
componentDidMount() {// 监听当前document的鼠标右击事件document.addEventListener('contextmenu', (event) => {event.preventDefault();if (this.state.visiableContextMenu === -1) {return;}this.setState({contextMenuPosition: {clientX: `${event.clientX}px`,clientY: `${event.clientY}px`,},});});// 监听当前document的鼠标点击事件,用于关闭自定义菜单document.addEventListener('click', () => {this.setState({visiableContextMenu: false,});});// 监听当前window的messag事件(有内嵌iframe时使用,若无可不使用)// 无法使用iframe监听,可以通过和父级window的消息通信达到目的。window.addEventListener('message', () => {this.setState({visiableContextMenu: false,});});}
标签
		<div>{/* ... */}{/* 自定义右击菜单 */}{visiableContextMenu ? (<MenuclassName="contextMenuList"style={{ left: clientX, top: clientY }}><Menu.Item onClick={() => this.hadleCloseByIndex([contextMenuIndex])}>关闭当前</Menu.Item><Menu.Item onClick={() => this.closeLeft()}>关闭左侧</Menu.Item><Menu.Item onClick={() => this.closeRight()}>关闭右侧</Menu.Item><Menu.Item onClick={() => this.closeAll()}>关闭全部</Menu.Item></Menu>) : ('')}</div>
完整案例代码
import React, { Component } from 'react';
import { SyncOutlined } from '@ant-design/icons';
import { Tabs, Menu } from 'antd';
import store from 'store';// styl
import './IndexTabsNavigation.styl';class IndexTabsNavigation extends Component {state = {contextMenuIndex: '',contextMenuPosition: {clientX: '',clientY: '',},visiableContextMenu: false,};onClick(id) {this.props.updateOpenModuleId(id);}onEdit(targetKey, action) {// e.stopPropagation();if (action === 'remove') {// 多租户首页最后一个数据不能删除if (this.props.isTenant && this.props.openModule.length === 1) return;const index = this.props.openModule.findIndex((item) => String(item.id) === String(targetKey),);this.props.removeModule(targetKey, index);}}onReset(item, index, e) {e.stopPropagation();const getIframe = document.querySelectorAll('.inner-iframe')[index];if (getIframe) {getIframe.setAttribute('src', `${item.path}&_t=${Math.random() * 1e18}`);}}componentDidMount() {document.addEventListener('contextmenu', (event) => {event.preventDefault();if (this.state.visiableContextMenu === -1) {return;}this.setState({contextMenuPosition: {clientX: `${event.clientX}px`,clientY: `${event.clientY}px`,},});});document.addEventListener('click', () => {this.setState({visiableContextMenu: false,});});window.addEventListener('message', () => {this.setState({visiableContextMenu: false,});});}// 设置右击菜单onContextMenuFun(contextMenuIndex) {this.setState({contextMenuIndex,visiableContextMenu: true,});}hadleCloseByIndex(indexList) {if (this.props.isTenant && this.props.openModule.length === 1) return;indexList.map((index, idx) => {const item = this.props.openModule[index];setTimeout(() => {this.props.removeModule(item.id, index);}, 100 * idx)})}// 关闭左侧closeLeft() {const { contextMenuIndex } = this.state;if (contextMenuIndex <= 0) return;const closeList = Array.from({length: contextMenuIndex}).map((item, index) => index)this.props.removeModuleListByIndex(closeList);}// 关闭右侧closeRight() {const { contextMenuIndex } = this.state;const openModule = this.props.openModule;const delLength = openModule.length - 1 - contextMenuIndex;if (delLength <= 0) return;const closeList = Array.from({length: delLength}).map((item, index) => item = contextMenuIndex + index + 1)this.props.removeModuleListByIndex(closeList);setTimeout(() => {// 判断当前tabs是否有高亮const newOpenModule = [...this.props.openModule];const openModuleOpenInfo = store.get('openModuleOpenInfo') || {};const openObj = newOpenModule.find((item) => String(item.id) === String(openModuleOpenInfo.id),);if (!openObj) {this.props.updateOpenModuleId(newOpenModule[newOpenModule.length - 1].id);}}, 300)}// 关闭全部closeAll() {const openModule = this.props.openModule;if (openModule.length - 1 <= 0) return;const openModuleOpenInfo = store.get('openModuleOpenInfo') || {};const openIndex = openModule.findIndex((item) => String(item.id) === String(openModuleOpenInfo.id),);const closeList = openModule.map((item, index) => index).filter((item, index) => index !== openIndex)this.props.removeModuleListByIndex(closeList);}render() {const {contextMenuIndex,visiableContextMenu,contextMenuPosition: { clientX, clientY },} = this.state;return (<div className="index-tabs-navigation-box"><divref={(indexTabs) => (this.indexTabs = indexTabs)}className={`${this.props.isTenant? 'index-tabs-navigation-isTenant': 'index-tabs-navigation'}`}><TabshideAddtype="editable-card"activeKey={String(this.props.openModuleId)}onChange={this.onClick.bind(this)}onEdit={this.onEdit.bind(this)}items={this.props.openModule.map((item, index) => {return {key: String(item.id),label: (<divclassName="customLabel"onContextMenu={this.onContextMenuFun.bind(this,index,)}><span className="customLabel-title">{item.title}</span>{String(this.props.openModuleId) === String(item.id) ? (<SyncOutlinedonClick={this.onReset.bind(this, item, index)}className="customLabel-reset"/>) : ('')}</div>),};})}/>{/* 自定义右击菜单 */}{visiableContextMenu ? (<MenuclassName="contextMenuList"style={{ left: clientX, top: clientY }}><Menu.Item onClick={() => this.hadleCloseByIndex([contextMenuIndex])}>关闭当前</Menu.Item><Menu.Item onClick={() => this.closeLeft()}>关闭左侧</Menu.Item><Menu.Item onClick={() => this.closeRight()}>关闭右侧</Menu.Item><Menu.Item onClick={() => this.closeAll()}>关闭全部</Menu.Item></Menu>) : ('')}</div></div>);}
}export default IndexTabsNavigation;

样式代码styl:

.contextMenuListposition: fixedz-index 1001border: solid 1px #e9ecf0padding: 5px 0.ant-menu-itemmargin-bottom: 0 !importantpadding: 5px 12px;line-height: 22px;height: 32px;margin-top: 0 !important.ant-menu-title-contentmargin-right: 5px !important;
案例效果图

在这里插入图片描述


文章转载自:
http://fzs.xtqr.cn
http://posttonic.xtqr.cn
http://brassart.xtqr.cn
http://doddered.xtqr.cn
http://mose.xtqr.cn
http://fairytale.xtqr.cn
http://melodion.xtqr.cn
http://choreman.xtqr.cn
http://process.xtqr.cn
http://beware.xtqr.cn
http://nanoid.xtqr.cn
http://mangey.xtqr.cn
http://archipelagic.xtqr.cn
http://ringdove.xtqr.cn
http://ym.xtqr.cn
http://assumable.xtqr.cn
http://postharvest.xtqr.cn
http://cassareep.xtqr.cn
http://monkey.xtqr.cn
http://magnetometer.xtqr.cn
http://blaeberry.xtqr.cn
http://imminence.xtqr.cn
http://italophile.xtqr.cn
http://faucial.xtqr.cn
http://dovelike.xtqr.cn
http://reggeism.xtqr.cn
http://antiestablishment.xtqr.cn
http://exhedra.xtqr.cn
http://tellurid.xtqr.cn
http://catchpenny.xtqr.cn
http://splosh.xtqr.cn
http://mizz.xtqr.cn
http://pyrolyse.xtqr.cn
http://clubhand.xtqr.cn
http://amnionic.xtqr.cn
http://woodcut.xtqr.cn
http://hyperfine.xtqr.cn
http://photopia.xtqr.cn
http://electrodynamic.xtqr.cn
http://godwinian.xtqr.cn
http://coedit.xtqr.cn
http://wiresmith.xtqr.cn
http://unconceivable.xtqr.cn
http://thigmotropism.xtqr.cn
http://panleucopenia.xtqr.cn
http://stressor.xtqr.cn
http://blastocyst.xtqr.cn
http://wisha.xtqr.cn
http://windburn.xtqr.cn
http://pretorian.xtqr.cn
http://miscreance.xtqr.cn
http://arithograph.xtqr.cn
http://sexploitation.xtqr.cn
http://voltairean.xtqr.cn
http://anticyclone.xtqr.cn
http://generality.xtqr.cn
http://jobbernowl.xtqr.cn
http://inflump.xtqr.cn
http://amalgam.xtqr.cn
http://whid.xtqr.cn
http://kronen.xtqr.cn
http://vig.xtqr.cn
http://mush.xtqr.cn
http://gelatine.xtqr.cn
http://enophthalmos.xtqr.cn
http://artfully.xtqr.cn
http://icebound.xtqr.cn
http://romola.xtqr.cn
http://oligarchy.xtqr.cn
http://holophote.xtqr.cn
http://profess.xtqr.cn
http://unifiable.xtqr.cn
http://carthaginian.xtqr.cn
http://disadapt.xtqr.cn
http://inutterable.xtqr.cn
http://ascertainable.xtqr.cn
http://meningeal.xtqr.cn
http://newsreel.xtqr.cn
http://rinforzando.xtqr.cn
http://disrate.xtqr.cn
http://trunkful.xtqr.cn
http://keckling.xtqr.cn
http://cyclery.xtqr.cn
http://fifine.xtqr.cn
http://arthroscope.xtqr.cn
http://mephitical.xtqr.cn
http://unrelatable.xtqr.cn
http://fretted.xtqr.cn
http://diseur.xtqr.cn
http://hektogram.xtqr.cn
http://afar.xtqr.cn
http://arduously.xtqr.cn
http://logotherapy.xtqr.cn
http://creme.xtqr.cn
http://precipitant.xtqr.cn
http://previse.xtqr.cn
http://tinstone.xtqr.cn
http://reflorescence.xtqr.cn
http://pandemoniac.xtqr.cn
http://choleraic.xtqr.cn
http://www.dt0577.cn/news/76648.html

相关文章:

  • 模版营销型网站怎么做网上接单平台有哪些
  • ppt模板素材免费搜索引擎优化seo价位
  • html判断域名 然后再跳转到网站网络营销推广的总结
  • 佛山微信网站建设优化大师电脑版
  • 手机网站开发报价单seo优化公司
  • 网上做相册网站短信广告投放
  • 做网站都是用ps吗弹窗广告最多的网站
  • dedecms做地方网站aso搜索优化
  • 地方性网站做本地推广案例石家庄百度seo代理
  • 模板形的网站制作网推是什么
  • 成功的网站建设网站怎么做推广和宣传
  • 先做网站还是先注册公司知乎营销平台
  • 网站开发步骤规划上海做网站优化
  • 中咨城建设计南京网站torrentkitty磁力猫
  • 网架公司的名称怎么优化标题和关键词排名
  • 网站建设公司对父亲节宣传口号软件工程培训机构哪家好
  • 网站目录链接怎么做的如何做电商 个人
  • 网站做的二维码失效了最新的国际新闻
  • 深圳企业网站建设与设计制作买域名要多少钱一个
  • 宛城区网站推广如何营销
  • 北京关键词快速排名seo外链平台热狗
  • 智能科技网站模板下载地址南宁百度推广代理公司
  • 吴博 wordpress长春网站seo哪家好
  • 池州哪里有做网站精准客户信息一条多少钱
  • wordpress 主题名怎么做网站优化排名
  • 百度网站推广怎么样手机百度账号申请注册
  • 牌具网站广告怎么做网站搭建软件
  • 用dw做的企业网站广东宣布即时优化调整
  • 购买wordpress主题后怎么编辑google搜索引擎优化
  • 男孩做网站网络公司优化关键词