记录--vue 拉伸指令

news2024/12/25 8:50:49

这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助

前言

在我们项目开发中,经常会有布局拉伸的需求,接下来 让我们一步步用 vue指令 实现这个需求

动手开发

在线体验

codesandbox.io/s/dawn-cdn-…

常规使用

解决拉伸触发时机

既然我们使用了指令的方式,也就是牺牲了组件方式的绑定事件的便捷性.

那么我们如何来解决这个触发时机的问题呢?

在参考了 Element UI 的表格拉伸功能后,笔者受到了启发

 有点抽象,这个红色区域可不是真实节点,只是笔者模拟的一个 boder-right 多说无益 直接上代码吧

const pointermove = e => {
    const { right } = el.getBoundingClientRect() // 获取到节点的右边界
    const { clientX } = e // 此时鼠标位置
    if (right - clientX < 8) // 表明在右边界的 8px 的过渡区 可以拉伸
}

实现一个简单的右拉伸

下面让我们来实现一个简单的右拉伸功能, 既然用指令 肯定是越简单越好

笔者决定用 vue提供的 修饰符, v-resize.right

实现 v-resize.right

1.首先我们创建两个相邻 div

<template>
  <div class="container">
    <div
      v-resize.right
      class="left"
    />
    <div class="right" />
  </div>
</template>
<style lang="scss" scoped>
.container {
  width: 400px;
  height: 100px;
  > div {
    float: left;
    height: 100%;
    width: 50%;
  }
  .left {
    background-color: lightcoral;
  }
  .right {
    background-color: lightblue;
  }
}
</style>

2.实现 resize 触发时机

export const resize = {
  inserted: function(el, binding) {
    el.addEventListener('pointermove', (e) => {
      const { right } = el.getBoundingClientRect()
      if (right - e.clientX < 8) {
        // 此时表明可以拉伸,时机成熟
        el.style.cursor = 'col-resize'
      } else {
        el.style.cursor = ''
      }
    })
  }
}

3.实现右拉伸功能

el.addEventListener('pointerdown', (e) => {
  const rightDom = el.nextElementSibling // 获取右节点
  const startX = e.clientX // 获取当前点击坐标

  const { width } = el.getBoundingClientRect() // 获取当前节点宽度
  const { width: nextWidth } = rightDom.getBoundingClientRect() // 获取右节点宽度
  el.setPointerCapture(e.pointerId) // HTML5 的 API 自行百度~

  const onDocumentMouseMove = (e) => {
    const offsetX = e.clientX - startX // 此时的 x 坐标偏差
    // 更新左右节点宽度
    el.style.width = width + offsetX + 'px'
    rightDom.style.width = nextWidth - offsetX + 'px'
  }
  // 因为此时我们要在整个屏幕移动 所以我们要在 document 挂上 mousemove
  document.addEventListener('mousemove',onDocumentMouseMove)

让我们看看此时的效果

会发现有两个问题

  1. 左边宽度会>左右之和,右边宽度会 < 0
  2. 当我们鼠标弹起的时候 还能继续拉伸

让我们首先解决第一个问题

方案一:限制最小宽度
const MIN_WIDTH = 10
document.addEventListener('mousemove', (e) => {
    const offsetX = e.clientX - startX // 此时的 x 坐标偏差
    +if (width + offsetX < MIN_WIDTH || nextWidth - offsetX < MIN_WIDTH) return
    // 更新左右节点宽度
    el.style.width = width + offsetX + 'px'
    rightDom.style.width = nextWidth - offsetX + 'px'
})

第二个问题,其实非常简单

方案二:鼠标弹起后释放对应拉伸事件

el.addEventListener('pointerup', (e) => {
    el.releasePointerCapture(e.pointerId)
    document.removeEventListener('mousemove', onDocumentMouseMove)
})

此时最最最基础的 v-resize 左右拉伸版本 我们已经实现了,来看下效果吧

 看下此时的完整代码

export const resize = {
  inserted: function (el, binding) {
    el.addEventListener('pointermove', (e) => {
      const { right } = el.getBoundingClientRect()
      if (right - e.clientX < 8) {
        // 此时表明可以拉伸
        el.style.cursor = 'col-resize'
      } else {
        el.style.cursor = ''
      }
    })

    const MIN_WIDTH = 10

    el.addEventListener('pointerdown', (e) => {
      const rightDom = el.nextElementSibling // 获取右节点
      const startX = e.clientX // 获取当前点击坐标

      const { width } = el.getBoundingClientRect() // 获取当前节点宽度
      const { width: nextWidth } = rightDom.getBoundingClientRect() // 获取右节点宽度
      el.setPointerCapture(e.pointerId) // HTML5 的 API 自行百度~

      const onDocumentMouseMove = (e) => {
        const offsetX = e.clientX - startX // 此时的 x 坐标偏差
        if (width + offsetX < MIN_WIDTH || nextWidth - offsetX < MIN_WIDTH) {
          return
        }
        // 更新左右节点宽度
        el.style.width = width + offsetX + 'px'
        rightDom.style.width = nextWidth - offsetX + 'px'
      }
      // 因为此时我们要在整个屏幕移动 所以我们要在 document 挂上 mousemove
      document.addEventListener('mousemove', onDocumentMouseMove)

      el.addEventListener('pointerup', (e) => {
        el.releasePointerCapture(e.pointerId)
        document.removeEventListener('mousemove', onDocumentMouseMove)
      })
    })
  },
}

作为 一名 优秀的前端性能优化专家,红盾大大已经开始吐槽,这么多 EventListener 都不移除吗? 还有'top' 'left'这些硬编码,能维护吗?

是的,后续代码我们将会移除这些被绑定的事件,以及处理硬编码(此处非重点 不做赘叙)

实现完 右拉伸 想必你对 左,上,下拉伸 也已经有了自己的思路

开始进阶

接下来让我们看下这种场景

我们 想实现一个 两边能同时拉伸的功能, 也就是 v-resize.left.right

实现左右拉伸功能

这种场景比较复杂,就需要我们维护一个拉伸方向上的变量 position

实现 v-resize.left.right

export const resize = {
  inserted: function (el, binding) {
    let position = '',
      resizing = false
    el.addEventListener('pointermove', (e) => {
      if (resizing) return
      const { left, right } = el.getBoundingClientRect()
      const { clientX } = e
      if (right - clientX < 8) {
        position = 'right' // 此时表明右拉伸
        el.style.cursor = 'col-resize'
      } else if (clientX - left < 8) {
        position = 'left' // 此时表明左拉伸
        el.style.cursor = 'col-resize'
      } else {
        position = ''
        el.style.cursor = ''
      }
    })

    const MIN_WIDTH = 10

    el.addEventListener('pointerdown', (e) => {
      if (position === '') return
      const sibling = position === 'right' ? el.nextElementSibling : el.previousElementSibling // 获取相邻节点
      const startX = e.clientX // 获取当前点击坐标

      const { width } = el.getBoundingClientRect() // 获取当前节点宽度
      const { width: siblingWidth } = sibling.getBoundingClientRect() // 获取右节点宽度
      el.setPointerCapture(e.pointerId) // HTML5 的 API 自行百度~

      const onDocumentMouseMove = (e) => {
        resizing = true
        if (position === '') return
        const offsetX = e.clientX - startX
        const _elWidth = position === 'right' ? width + offsetX : width - offsetX //判断左右拉伸 所影响的当前节点宽度

        const _siblingWidth = position === 'right' ? siblingWidth - offsetX : siblingWidth + offsetX //判断左右拉伸 所影响的相邻节点宽度
        if (_elWidth <= MIN_WIDTH || _siblingWidth <= MIN_WIDTH) return

        // 更新左右节点宽度
        el.style.width = _elWidth + 'px'
        sibling.style.width = _siblingWidth + 'px'
      }

      document.addEventListener('mousemove', onDocumentMouseMove)

      el.addEventListener('pointerup', (e) => {
        position = ''
        resizing = false
        el.releasePointerCapture(e.pointerId)
        document.removeEventListener('mousemove', onDocumentMouseMove)
      })
    })
  },
}
看下此时的效果

非常丝滑, 当然 我们还需要考虑 传递 最小宽度 最大宽度 过渡区 等多种业务属性,但是这对于各位彦祖来说都是鸡毛蒜皮的小事. 自行改造就行了

完整代码

Js版本

const elEventsWeakMap = new WeakMap()
const MIN_WIDTH = 50
const MIN_HEIGHT = 50
const TRIGGER_SIZE = 8
const TOP = 'top'
const BOTTOM = 'bottom'
const LEFT = 'left'
const RIGHT = 'right'
const COL_RESIZE = 'col-resize'
const ROW_RESIZE = 'row-resize'

function getElStyleAttr(element, attr) {
  const styles = window.getComputedStyle(element)
  return styles[attr]
}

function getSiblingByPosition(el, position) {
  const siblingMap = {
    left: el.previousElementSibling,
    right: el.nextElementSibling,
    bottom: el.nextElementSibling,
    top: el.previousElementSibling
  }
  return siblingMap[position]
}

function getSiblingsSize(el, attr) {
  const siblings = el.parentNode.childNodes
  return [...siblings].reduce((prev, next) => (next.getBoundingClientRect()[attr] + prev), 0)
}

function updateSize({
  el,
  sibling,
  formatter = 'px',
  elSize,
  siblingSize,
  attr = 'width'
}) {
  let totalSize = elSize + siblingSize
  if (formatter === 'px') {
    el.style[attr] = elSize + formatter
    sibling.style[attr] = siblingSize + formatter
  } else if (formatter === 'flex') {
    totalSize = getSiblingsSize(el, attr)
    el.style.flex = elSize / totalSize * 10 // 修复 flex-grow <1
    sibling.style.flex = siblingSize / totalSize * 10
  }
}

const initResize = ({
  el,
  positions,
  minWidth = MIN_WIDTH,
  minHeight = MIN_HEIGHT,
  triggerSize = TRIGGER_SIZE,
  formatter = 'px'
}) => {
  if (!el) return
  const resizeState = {}
  const defaultCursor = getElStyleAttr(el, 'cursor')
  const elStyle = el.style

  const canLeftResize = positions.includes(LEFT)
  const canRightResize = positions.includes(RIGHT)
  const canTopResize = positions.includes(TOP)
  const canBottomResize = positions.includes(BOTTOM)

  if (!canLeftResize && !canRightResize && !canTopResize && !canBottomResize) { return } // 未指定方向

  const pointermove = (e) => {
    if (resizeState.resizing) return
    e.preventDefault()
    const { left, right, top, bottom } = el.getBoundingClientRect()
    const { clientX, clientY } = e
    // 左右拉伸
    if (canLeftResize || canRightResize) {
      if (clientX - left < triggerSize) resizeState.position = LEFT
      else if (right - clientX < triggerSize) resizeState.position = RIGHT
      else resizeState.position = ''

      if (resizeState.position === '') {
        elStyle.cursor = defaultCursor
      } else {
        if (getSiblingByPosition(el, resizeState.position)) { elStyle.cursor = COL_RESIZE }
        e.stopPropagation()
      }
    } else if (canTopResize || canBottomResize) {
      // 上下拉伸
      if (clientY - top < triggerSize) resizeState.position = TOP
      else if (bottom - clientY < triggerSize) resizeState.position = BOTTOM
      else resizeState.position = ''

      if (resizeState.position === '') {
        elStyle.cursor = defaultCursor
      } else {
        if (getSiblingByPosition(el, resizeState.position)) { elStyle.cursor = ROW_RESIZE }
        e.stopPropagation()
      }
    }
  }

  const pointerleave = (e) => {
    e.stopPropagation()
    resizeState.position = ''
    elStyle.cursor = defaultCursor
    el.releasePointerCapture(e.pointerId)
  }
  const pointerdown = (e) => {
    const { resizing, position } = resizeState
    if (resizing || !position) return

    if (position) e.stopPropagation() // 如果当前节点存在拉伸方向 需要阻止冒泡(用于嵌套拉伸)
    el.setPointerCapture(e.pointerId)

    const isFlex = getElStyleAttr(el.parentNode, 'display') === 'flex'
    if (isFlex) formatter = 'flex'

    resizeState.resizing = true
    resizeState.startPointerX = e.clientX
    resizeState.startPointerY = e.clientY

    const { width, height } = el.getBoundingClientRect()

    const sibling = getSiblingByPosition(el, position)
    if (!sibling) {
      console.error('未找到兄弟节点', position)
      return
    }

    const rectSibling = sibling.getBoundingClientRect()

    const { startPointerX, startPointerY } = resizeState
    const onDocumentMouseMove = (e) => {
      if (!resizeState.resizing) return
      elStyle.cursor =
        canLeftResize || canRightResize ? COL_RESIZE : ROW_RESIZE
      const { clientX, clientY } = e

      if (position === LEFT || position === RIGHT) {
        const offsetX = clientX - startPointerX
        const elSize = position === RIGHT ? width + offsetX : width - offsetX

        const siblingSize =
          position === RIGHT
            ? rectSibling.width - offsetX
            : rectSibling.width + offsetX
        if (elSize <= minWidth || siblingSize <= minWidth) return

        updateSize({ el, sibling, elSize, siblingSize, formatter })
      } else if (position === TOP || position === BOTTOM) {
        const offsetY = clientY - startPointerY
        const elSize =
          position === BOTTOM ? height + offsetY : height - offsetY

        const siblingSize =
          position === BOTTOM
            ? rectSibling.height - offsetY
            : rectSibling.height + offsetY
        if (elSize <= minHeight || siblingSize <= minHeight) return

        updateSize({ el, sibling, elSize, siblingSize, formatter })
      }
    }

    const onDocumentMouseUp = (e) => {
      document.removeEventListener('mousemove', onDocumentMouseMove)
      document.removeEventListener('mouseup', onDocumentMouseUp)
      resizeState.resizing = false
      elStyle.cursor = defaultCursor
    }

    document.addEventListener('mousemove', onDocumentMouseMove)
    document.addEventListener('mouseup', onDocumentMouseUp)
  }

  const bindElEvents = () => {
    el.addEventListener('pointermove', pointermove)
    el.addEventListener('pointerleave', pointerleave)
    el.addEventListener('pointerup', pointerleave)
    el.addEventListener('pointerdown', pointerdown)
  }

  const unBindElEvents = () => {
    el.removeEventListener('pointermove', pointermove)
    el.removeEventListener('pointerleave', pointerleave)
    el.removeEventListener('pointerup', pointerleave)
    el.removeEventListener('pointerdown', pointerdown)
  }

  bindElEvents()

  // 设置解绑事件
  elEventsWeakMap.set(el, unBindElEvents)
}
export const resize = {
  inserted: function(el, binding) {
    const { modifiers, value } = binding
    const positions = Object.keys(modifiers)
    initResize({ el, positions, ...value })
  },
  unbind: function(el) {
    const unBindElEvents = elEventsWeakMap.get(el)
    unBindElEvents()
  }
}

Ts版本

import type { DirectiveBinding } from 'vue'

const elEventsWeakMap = new WeakMap()
const MIN_WIDTH = 50
const MIN_HEIGHT = 50
const TRIGGER_SIZE = 8

enum RESIZE_CURSOR {
  COL_RESIZE = 'col-resize',
  ROW_RESIZE = 'row-resize',
}

enum POSITION {
  TOP = 'top',
  BOTTOM = 'bottom',
  LEFT = 'left',
  RIGHT = 'right',
}

type Positions = [POSITION.TOP, POSITION.BOTTOM, POSITION.LEFT, POSITION.RIGHT]

interface ResizeState {
  resizing: boolean
  position?: POSITION
  startPointerX?: number
  startPointerY?: number
}
type WidthHeight = 'width' | 'height'

type ElAttr = WidthHeight | 'cursor' | 'display' // 后面补充

type ResizeFormatter = 'px' | 'flex'

interface ResizeInfo {
  el: HTMLElement
  positions: Positions
  minWidth: number
  minHeight: number
  triggerSize: number
  formatter: ResizeFormatter
}

function getElStyleAttr(element: HTMLElement, attr: ElAttr) {
  const styles = window.getComputedStyle(element)
  return styles[attr]
}

function getSiblingByPosition(el: HTMLElement, position: POSITION) {
  const siblingMap = {
    left: el.previousElementSibling,
    right: el.nextElementSibling,
    bottom: el.nextElementSibling,
    top: el.previousElementSibling,
  }
  return siblingMap[position]
}

function getSiblingsSize(el: HTMLElement, attr: WidthHeight) {
  const siblings = (el.parentNode && el.parentNode.children) || []
  return [...siblings].reduce(
    (prev, next) => next.getBoundingClientRect()[attr] + prev,
    0,
  )
}

function updateSize({
  el,
  sibling,
  formatter = 'px',
  elSize,
  siblingSize,
  attr = 'width',
}: {
  el: HTMLElement
  sibling: HTMLElement
  formatter: ResizeFormatter
  elSize: number
  siblingSize: number
  attr?: WidthHeight
}) {
  let totalSize = elSize + siblingSize
  if (formatter === 'px') {
    el.style[attr] = elSize + formatter
    sibling.style[attr] = siblingSize + formatter
  } else if (formatter === 'flex') {
    totalSize = getSiblingsSize(el as HTMLElement, attr)
    el.style.flex = `${(elSize / totalSize) * 10}` // 修复 flex-grow <1
    sibling.style.flex = `${(siblingSize / totalSize) * 10}`
  }
}

const initResize = ({
  el,
  positions,
  minWidth = MIN_WIDTH,
  minHeight = MIN_HEIGHT,
  triggerSize = TRIGGER_SIZE,
  formatter = 'px',
}: ResizeInfo) => {
  if (!el || !(el instanceof HTMLElement)) return
  const resizeState: ResizeState = {
    resizing: false,
  }
  const defaultCursor = getElStyleAttr(el, 'cursor')
  const elStyle = el.style

  const canLeftResize = positions.includes(POSITION.LEFT)
  const canRightResize = positions.includes(POSITION.RIGHT)
  const canTopResize = positions.includes(POSITION.TOP)
  const canBottomResize = positions.includes(POSITION.BOTTOM)

  if (!canLeftResize && !canRightResize && !canTopResize && !canBottomResize) {
    return
  } // 未指定方向

  const pointermove = (e: PointerEvent) => {
    if (resizeState.resizing) return
    e.preventDefault()
    const { left, right, top, bottom } = el.getBoundingClientRect()
    const { clientX, clientY } = e
    // 左右拉伸
    if (canLeftResize || canRightResize) {
      if (clientX - left < triggerSize) resizeState.position = POSITION.LEFT
      else if (right - clientX < triggerSize)
        resizeState.position = POSITION.RIGHT
      else resizeState.position = undefined

      if (resizeState.position === undefined) {
        elStyle.cursor = defaultCursor
      } else {
        if (getSiblingByPosition(el, resizeState.position)) {
          elStyle.cursor = RESIZE_CURSOR.COL_RESIZE
        }
        e.stopPropagation()
      }
    } else if (canTopResize || canBottomResize) {
      // 上下拉伸
      if (clientY - top < triggerSize) resizeState.position = POSITION.TOP
      else if (bottom - clientY < triggerSize)
        resizeState.position = POSITION.BOTTOM
      else resizeState.position = undefined

      if (resizeState.position === undefined) {
        elStyle.cursor = defaultCursor
      } else {
        if (getSiblingByPosition(el, resizeState.position)) {
          elStyle.cursor = RESIZE_CURSOR.ROW_RESIZE
        }
        e.stopPropagation()
      }
    }
  }

  const pointerleave = (e: PointerEvent) => {
    e.stopPropagation()
    resizeState.position = undefined
    elStyle.cursor = defaultCursor
    el.releasePointerCapture(e.pointerId)
  }
  const pointerdown = (e: PointerEvent) => {
    const { resizing, position } = resizeState
    if (resizing || !position) return

    if (position) e.stopPropagation() // 如果当前节点存在拉伸方向 需要阻止冒泡(用于嵌套拉伸)
    el.setPointerCapture(e.pointerId)

    if (el.parentElement) {
      const isFlex = getElStyleAttr(el.parentElement, 'display') === 'flex'
      if (isFlex) formatter = 'flex'
    }

    resizeState.resizing = true
    resizeState.startPointerX = e.clientX
    resizeState.startPointerY = e.clientY

    const { width, height } = el.getBoundingClientRect()

    const sibling: HTMLElement = getSiblingByPosition(
      el,
      position,
    ) as HTMLElement
    if (!sibling || !(sibling instanceof HTMLElement)) {
      console.error('未找到兄弟节点', position)
      return
    }

    const rectSibling = sibling.getBoundingClientRect()

    const { startPointerX, startPointerY } = resizeState
    const onDocumentMouseMove = (e: MouseEvent) => {
      if (!resizeState.resizing) return
      elStyle.cursor =
        canLeftResize || canRightResize
          ? RESIZE_CURSOR.COL_RESIZE
          : RESIZE_CURSOR.ROW_RESIZE
      const { clientX, clientY } = e

      if (position === POSITION.LEFT || position === POSITION.RIGHT) {
        const offsetX = clientX - startPointerX
        const elSize =
          position === POSITION.RIGHT ? width + offsetX : width - offsetX

        const siblingSize =
          position === POSITION.RIGHT
            ? rectSibling.width - offsetX
            : rectSibling.width + offsetX
        if (elSize <= minWidth || siblingSize <= minWidth) return

        updateSize({ el, sibling, elSize, siblingSize, formatter })
      } else if (position === POSITION.TOP || position === POSITION.BOTTOM) {
        const offsetY = clientY - startPointerY
        const elSize =
          position === POSITION.BOTTOM ? height + offsetY : height - offsetY

        const siblingSize =
          position === POSITION.BOTTOM
            ? rectSibling.height - offsetY
            : rectSibling.height + offsetY
        if (elSize <= minHeight || siblingSize <= minHeight) return

        updateSize({
          el,
          sibling,
          elSize,
          siblingSize,
          formatter,
          attr: 'height',
        })
      }
    }

    const onDocumentMouseUp = () => {
      document.removeEventListener('mousemove', onDocumentMouseMove)
      document.removeEventListener('mouseup', onDocumentMouseUp)
      resizeState.resizing = false
      elStyle.cursor = defaultCursor
    }

    document.addEventListener('mousemove', onDocumentMouseMove)
    document.addEventListener('mouseup', onDocumentMouseUp)
  }

  const bindElEvents = () => {
    el.addEventListener('pointermove', pointermove)
    el.addEventListener('pointerleave', pointerleave)
    el.addEventListener('pointerup', pointerleave)
    el.addEventListener('pointerdown', pointerdown)
  }

  const unBindElEvents = () => {
    el.removeEventListener('pointermove', pointermove)
    el.removeEventListener('pointerleave', pointerleave)
    el.removeEventListener('pointerup', pointerleave)
    el.removeEventListener('pointerdown', pointerdown)
  }

  bindElEvents()

  // 设置解绑事件
  elEventsWeakMap.set(el, unBindElEvents)
}
export const resize = {
  mounted: function (el: HTMLElement, binding: DirectiveBinding) {
    const { modifiers, value } = binding
    const positions = Object.keys(modifiers)
    initResize({ el, positions, ...value })
  },
  beforeUnmount: function (el: HTMLElement) {
    const unBindElEvents = elEventsWeakMap.get(el)
    unBindElEvents()
  },
}

本文转载于:

https://juejin.cn/post/7250402828378914876

如果对您有所帮助,欢迎您点个关注,我会定时更新技术文档,大家一起讨论学习,一起进步。

 

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

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

相关文章

10.引入导航栏样式

1.导航栏为单独一个组件 在element-ui中引入导航栏的代码 &#xff01;注意 内容一定要在template中&#xff0c;否则bug遇到很久 <template><div><!-- 页面布局 --><el-container><!-- 侧边栏 --><el-aside width"200px"><…

模拟电子技术基础学习笔记二 杂质半导体

通过扩散工艺&#xff0c;在本征半导体中掺入少量合适的杂质元素&#xff0c;可得到杂质半导体。 按掺入的杂质元素不同&#xff0c;可形成N型半导体和P型半导体 控制掺入杂质元素的浓度&#xff0c;可以控制杂质半导体的导电性能。 一、N型半导体&#xff08;negative Semic…

独家首发!openEuler 主线集成 LuaJIT RISC-V JIT 技术

RISC-V SIG 预期随主线发布的 openEuler 23.09 创新版本会集成 LuaJIT RISC-V 支持。本次发版将提供带有完整 LuaJIT 支持的 RISC-V 环境并带有相关软件如 openResty 等软件的支持。 随着 RISC-V SIG 主线推动工作的进展&#xff0c;LuaJIT 和相关软件在 RISC-V 架构下的支持也…

活用 命令行通配符

本文是对 阮一峰老师命令行通配符教程[1]的学习与记录 通配符早于正则表达式出现,可以看作是原始的正则表达式. 其功能没有正则那么强大灵活,而胜在简单和方便. - 字符 切回上一个路径/分支 如图: !! 代表上一个命令, 如图: [Linux中“!"的神奇用法](https://www.cnblogs.…

【ES6】Promise.all用法

Promise.all()方法用于将多个 Promise 实例&#xff0c;包装成一个新的 Promise 实例。 const p Promise.all([p1, p2, p3]);上面代码中&#xff0c;Promise.all()方法接受一个数组作为参数&#xff0c;p1、p2、p3都是 Promise 实例&#xff0c;如果不是&#xff0c;就会先调…

华为数通方向HCIP-DataCom H12-821题库(单选题:181-200)

第181题 某管理员需要创建AS Path过滤器(ip as-path-iter)&#xff0c;允许AS_Path中包含65001的路由通过&#xff0c;那么以下哪一项配置是正确的? A、​​ip as-path-filter 1 permit 65001​​ B、​​ip as-path-filter 1 permit "65001​​ C、​​ip as-path-f…

开源电子合同签署平台小程序源码 在线签署电子合同小程序源码 合同在线签署源码

聚合市场上各类电子合同解决方案商&#xff0c;你无需一个一个的对接电子合同厂商&#xff0c;费时&#xff0c;费力&#xff0c;因为这个工作我们已经做了适配&#xff0c;你只需要一个接口就能使用我们的所有服务商&#xff0c;同时你还可以享受我们的接口渠道价格。 Mini-C…

Redis图文指南

1、什么是 Redis&#xff1f; Redis&#xff08;REmote DIctionary Service&#xff09;是一个开源的键值对数据库服务器。 Redis 更准确的描述是一个数据结构服务器。Redis 的这种特殊性质让它在开发人员中很受欢迎。 Redis不是通过迭代或者排序方式处理数据&#xff0c;而是…

weblogic/CVE-2018-2894文件上传漏洞复现

启动docker环境 查看帮助文档 环境启动后&#xff0c;访问http://your-ip:7001/console&#xff0c;即可看到后台登录页面。 执行docker-compose logs | grep password可查看管理员密码&#xff0c;管理员用户名为weblogic&#xff0c;密码为lFVAJ89F 登录后台页面&#xff0c;…

说说大表关联小表

分析&回答 Hive 大表和小表的关联 优先选择将小表放在内存中。小表不足以放到内存中&#xff0c;可以通过bucket-map-join(不清楚的话看底部文章)来实现&#xff0c;效果很明显。 两个表join的时候&#xff0c;其方法是两个join表在join key上都做hash bucket&#xff0c…

OceanBase 4.1解读:读写兼备的DBLink让数据共享“零距离”

梁长青&#xff0c;OceanBase 高级研发工程师&#xff0c;从事 SQL 执行引擎相关工作&#xff0c;目前主要负责 DBLink、单机引擎优化等方面工作。 沈大川&#xff0c;OceanBase 高级研发工程师&#xff0c;从事 SQL 执行引擎相关工作&#xff0c;曾参与 TPC-H 项目攻坚&#x…

为什么聊天头像ChatGPT是橙色的?

目录 ChatGPT的不同版本及其颜色 了解绿色和橙色的ChatGPT徽标 颜色变化的重要性 橙色标志的原因 故障排除和常见问题解答 常见问题3&#xff1a;如何查看ChatGPT的服务器状态&#xff1f; 常见问题4&#xff1a;如果使用ChatGPT时遇到错误&#xff0c;我该怎么办&#…

第 3 章 栈和队列(用递归调用求 Ackerman(m, n) 的值)

1. 示例代码&#xff1a; /* 用递归调用求 Ackerman(m, n) 的值 */#include <stdio.h>int Ackerman(int m, int n);int main(void) {int m 0, n 0;printf("Please input m and n: ");scanf_s("%d%d", &m, &n);printf("Ackerman(%d, …

信息安全-应用安全-蚂蚁集团软件供应链安全实践

8月10日&#xff0c;由悬镜安全主办、以“开源的力量”为主题的DSS 2023数字供应链安全大会在北京国家会议中心隆重召开。蚂蚁集团网络安全副总经理程岩出席并发表了《蚂蚁集团软件供应链安全实践》主题演讲。 图1 蚂蚁集团网络安全副总经理程岩发表主题演讲 以下为演讲实录&am…

css实现文字翻转效果

csss实现文字翻转效果 主要实现核心属性 direction: rtl; unicode-bidi: bidi-override; direction: rtl; 这个属性用于指定文本的方向为从右到左&#xff08;Right-to-Left&#xff09;。它常用于处理阿拉伯语、希伯来语等从右向左书写的文字样式。当设置了 direction: rtl; …

Java队列有哪些?8大常用Java队列总结

什么是队列? 队列是一种操作受限的线性表&#xff0c;只允许在表的前端&#xff08;front&#xff09;进行删除操作又称作出队&#xff0c;在表的后端进行插入操作&#xff0c;称为入队&#xff0c;符合先进先出&#xff08;First in First out&#xff09;的特性。在队尾插入…

Rstudio开不开了怎么办?R is taking longer to start than usual

Rstudio Server 启动时卡死 在使用 linux 服务器版 RstudioServer 的过程中&#xff0c;发现出现了一个问题&#xff0c;导致没有办法正常载入工作页面&#xff0c;网页提示信息是“R is taking longer to start than usual”&#xff0c;直接翻译过来就是“这次启动 R 会比平常…

Unity RenderStreaming 云渲染-黑屏

&#x1f96a;云渲染-黑屏 网页加载出来了&#xff0c;点击播放黑屏 &#xff0c;关闭防火墙即可&#xff01;&#xff01;&#xff01;&#xff01;

$attrs,$listeners

vue实现组件通信的方式有&#xff1a; 父子通信 父组件向子组件传递通过props定义各个属性来传递&#xff0c;子组件向父组件传递通过$emit触发事件 ref也可以访问组件实例跨级通信 vuex bus provide / inject $attrs / $listeners解释 $attrs / $listeners $attrs 将父组件中…

Django实现音乐网站 ⒂

使用Python Django框架制作一个音乐网站&#xff0c; 本篇主要是歌手详情页-基本信息、单曲列表功能开发实现内容。 目录 歌手基本信息 增加路由 显示视图 模板显示 推荐歌手跳转详情 歌手增加基本信息 表模型增加字段 数据表更新 基本信息增加内容渲染 歌手单曲列表…