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 🙏

© 2024 – Pkg Stats / Ryan Hefner

v-focus-next

v1.0.4

Published

vue表单指令,用于在表单中输入回车后,自动聚焦下一个表单元素

Downloads

34

Readme

v-focus-next

简介

v-focus-next是一个Vue指令,使用该指令后,在表单的某个元素中输入回车符,可以自动聚焦到下一个表单元素,避免了用户通过鼠标来回选中表单元素,大大提升了表单填写的效率和用户体验。

《演示效果》

v-focus-next的使用非常简单。

只需要为某个Dom或Vue组件(如div、form、ElForm等)绑定v-focus-next指令,则该Dom下的所有input/textarea自动支持回车聚焦功能,无需任何其他配置。

支持以下特性:

  • 默认会将所有input/textarea加入回车聚焦功能,也可通过指定className等方式,将部分表单元素支持回车聚焦。
  • 支持首个表单元素自动聚焦
  • 支持任意普通Dom元素和Vue组件
  • 自动过滤掉disable的元素及type为hidden、radio、checkbox、file、submit、reset的元素
  • 支持vue2/3

使用

安装

npm install v-focus-next

项目中引入

通过use方式,引入该指令中间件。

Vue3示例:

import { createApp } from 'vue'
import App from './App.vue'
import vFocusNext from "v-focus-next";

let app = createApp(App)
app.use(vFocusNext)  //通过中间件方式引入指令
app.mount('#app')

Vue2示例:

import Vue from 'vue'
import App from './App.vue'
import vFocusNext from "v-focus-next";

Vue.use(vFocusNext); //通过中间件方式引入指令

new Vue({
  render: h => h(App),
}).$mount('#app')

示例1

只需为某个父元素增加v-focus-next指令,则其中所有表单元素就拥有了回车聚焦功能。

 <div v-focus-next>
    <input placeholder="输入回车自动聚焦下一行"/>
    <input/>
    <input/>
    <input/>
    <input/>
    <textarea  />
</div>

Vue组件也是一样的,如为el-form添加v-focus-next指令。

<el-form v-focus-next >
    <el-form-item label="名称">
        <el-input v-model="form.name" id="name" />
    </el-form-item>
    <el-form-item label="年龄">
        <el-input v-model="form.age" id="age" disabled />
    </el-form-item>
 </el-form>

示例2:指定参与回车聚焦的元素

或许你不想所有表单元素都参与回车聚焦,比如只想让所有设置了class为'test'的元素参与回车聚焦,只需要设置 v-focus-next="'.test'",可设为querySelectorAll支持的参数形式。

<div v-focus-next="'.test'">
    <input class="test"/>
    <input />
    <input class="test"/>
</div>

示例3:自动聚焦首个元素

只需设置v-focus-next.autoFocus即可。

<div v-focus-next.autoFocus>
    <input />  //自动聚焦
    <input />
    <input />
</div>

赞助和微信交流

如果该项目确实帮助到了您,欢迎赞助,以鼓励我将更多的休息时间,投入到该项目的优化中,也欢迎赞助后添加微信交流:_hit757_

恳请各位大佬不吝点赞,开源不易,感谢支持~~