npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue3move

v2.1.2

Published

提供 v-drag 和 v-drop 分别表示可以拖元素和可以放置容器

Readme

提供 v-drag 和 v-drop 分别表示可以拖元素和可以放置容器

在 :dragOption 和 :dropOption 提供对应指令的参数

安装

import { createApp } from "vue";
# 推荐安装 tailwind , 因为用到了一些 className 样式
import "./tailwind.css";
import "./style.css";
import App from "./App.vue";

# 导入指令,后面use注册
import vue3move from "vue3move";

createApp(App).use(vue3move).mount("#app");

指令使用例子

<template>
  <div class="border p-2">
    拖拽起点:
    <div
      class="p-2 m-2 border-2"
      v-for="item in data1"
      :key="item.text"
      v-drag="{
        clone: true,
        createid: true,
        element: item,
        name: 'leftcom',
      }"
    >
      {{ item.text }}
    </div>
  </div>
  <div>
    放置区:
    <div
      class="min-h-72 w-96 border p-2"
      v-drop="{
        children: data2,
        allow: ['leftcom', 'maincom'],
        onAdd: onDropAdd,
        onMove: onDropMove,
      }"
    >
      <div
        v-for="item in data2"
        :key="item.id"
        v-drag="{
          element: item,
          brother: data2,
          name: 'maincom',
        }"
      >
        <input class="border" v-if="item.component == 'input'" />
        <select class="border" v-if="item.component == 'select'">
          <option>选项1</option>
          <option>选项2</option>
        </select>
        <table
          class="border w-full table-fixed"
          v-if="item.component == 'table'"
        >
          <tr v-for="(_, r) in 3">
            <td
              class="h-[32px] border"
              v-for="(_, c) in 2"
              v-drop="{
                limit: 1,
                children: item.children[r * 2 + c],
                allow: ['leftcom', 'maincom'],
                onAdd: onDropAdd,
                onMove: onDropMove,
              }"
            >
              <div
                v-for="child in item.children[r * 2 + c]"
                v-drag="{
                  element: child,
                  brother: item.children[r * 2 + c],
                  name: 'maincom',
                }"
              >
                <input class="border" v-if="child.component == 'input'" />
                <select class="border" v-if="child.component == 'select'">
                  <option>选项1</option>
                  <option>选项2</option>
                </select>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
  </div>
  <div></div>
</template>

<script lang="ts" setup>
import { reactive } from "vue";
interface EleType {
  [key: string]: any;
}

const data1 = reactive([
  {
    component: "input",
    text: "输入框",
  },
  {
    component: "select",
    text: "下拉框",
  },
  {
    component: "table",
    text: "布局容器",
    rows: 3,
    cols: 2,
    children: [],
  },
]);

const data2 = reactive<EleType[]>([]);

function onDropAdd(element, brother, index) {
  if (element.component == "table") {
    element.children = Array.from(Array(element.rows * element.cols), () => []);
  }
}
function onDropMove(element, brother, index) {}
</script>

参数说明

/**
 * v-drag 允许拖动
 * 
 第一种: 左侧控件列表参数
v-drag="{
  clone: true,
  createid: true,
  element: item,
  name: 'leftcom'
}"
 第二种:中间控件更改位置
v-drag="{
  element: ele,
  brother: elementsRef,
  name: 'maincom'
}"
  
 **** v-drop 允许放置
 第一种:中间容器
v-drop="{
  children: elementsRef,
  allow: ['leftcom', 'maincom'],
  onAdd: onDropAdd,
  onMove: onDropMove
}"
第二种:表格布局每格只能放1个
v-drop="{
  limit: 1,
  children: comBrother(r, c),
  allow: ['leftcom', 'maincom'],
  onAdd: onDropAdd,
  onMove: onDropMove
}"
 */