@branu-jp/v-drag

中文文档
0.1.0发布于 2018/08/18MITCommonJS近 30 天下载 2067

A Vue.js draggable directive

原始使用文档
文档目录5 节
  1. Installation
  2. Use
  3. Notes
  4. Options
  5. Other

v-drag - a supler simple, Vue.js draggable component.

Demo: https://branu-ws.github.io/v-drag/

Installation

npm:

npm install @branu-jp/v-drag

yarn:

yarn add @branu-jp/v-drag --save

Use

Node.js env (such a .vue components):

<template>
  <div>
    <div style="position: absolute;" v-drag>
    </div>
  </div>
</template>

<script>
import drag from '@branu-jp/v-drag'

export default {
  directives: {
    drag
  }
}
</script>

Browser env: coming soon.

Notes

An element with v-drag must have position: absolute; to be draggable.

Options

You may desire only one part of an element to be draggable. You can achieve this by passing a string which referes to an id as argument to v-drag.

<div id="header">
  <div v-drag:header>
    <div>
      Some text
    </div>
  </div>
</div>

This will result in any area that is not <div id="header"> not becoming draggable. One common use case is a modal, that is only draggable when the top area is clicked.

You can constrain the draggable object from leaving the viewpor by using the window-only modifier like so:

<div v-drag.window-only>
  This element cannot be dragged outside the window
</div>

Other

Built by, for and at BRANU. Our open source projects can be found on our npm page: https://www.npmjs.com/org/branu-jp

v-drag npm link: https://www.npmjs.com/package/@branu-jp/v-drag

版本与发布记录

@branu-jp/v-drag 共发布 11 个版本,首次发布于 2018/03/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.0latest2018/08/188 年前
0.0.102018/04/248 年前
0.0.92018/04/248 年前
0.0.82018/04/248 年前
0.0.72018/04/198 年前
0.0.62018/03/158 年前

关于 @branu-jp/v-drag 的常见问题

@branu-jp/v-drag 是什么?

A Vue.js draggable directive

如何安装 @branu-jp/v-drag?

在项目目录运行 npm install @branu-jp/v-drag,或使用 pnpm add / yarn add / bun add。

@branu-jp/v-drag 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/branu-jp__v-drag 是否存在。

@branu-jp/v-drag 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@branu-jp/v-drag 可以商用吗?

@branu-jp/v-drag 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@branu-jp/v-drag 的下载量有多少?

根据 npm 官方下载统计,@branu-jp/v-drag 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,067 次,日均约 69 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@branu-jp/v-drag 还在维护吗?

最新版本 0.1.0 发布于 2018/08/18(8 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/03/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。