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-cookie

v1.1.5

Published

一个用于操作cookie的Vue插件,使用简单,无依赖

Downloads

9

Readme

v-cookie

一个用于操作cookie的Vue插件,使用简单,无依赖

如果使用中遇到问题请联系: [email protected]

安装

npm i v-cookie -S

使用

import Vue from 'vue'

// 导入插件
import VCookie from 'v-cookie'

// 使用插件
Vue.use(VCookie);

简单示例


// 设置一个时效为8小时的cookie
this.$cookie.set('userID','xxx123',8)

// 获取一个cookie
let userID = this.$cookie.get('userID')

// 删除一个cookie
this.$cookie.del('userID')

// 设置一个自定义域名的cookie 
//设置cookie时加了域名和路径,删除时也要加上一模一样的,否则无法删除
this.$cookie.set('user','jack',48,'.baidu.com','/')

//删除这个域名
this.$cookie.del('user','.baidu.com','/')

方法

1. 设置cookie

/**
 * set cookie
 * @param {string} cname cookie名
 * @param {string} cvalue cookie值
 * @param {number} ctime 过期时间(单位:小时)默认值1天
 * @param {string} domain 域名 (默认为当前的域名)
 * @param {string} path   路径 (默认为 / )
 * 
 */

  VCookie.set(cname,cvalue,ctime,domain,path)

2. 获取cookie

    /**
     * get cookie
     * @param {string} cname 要获取的coolie名
     * @returns {string || null} 返回找到的cookie值,如果找不到,返回null
     */

    VCookie.get(cname)

3. 删除cookie

    /**
     * del cookie
     * @param {string} cname 要删除的cookie名
     * @param {string} domain 要删除cookie的域名
     * @param {string} path 要删除cookie的路径
     * 
     * ! tips: 设置域名是如果没有传域名和路径,删除时可以不传。 设置时传了,删除时就要传一模一样的,否则无法删除
     */

    VCookie.del(cname,domain,path)

作者


{
    "Nickname" : "木仔四毛",
    "Emial" : "[email protected]",
    "Github" : "https://github.com/muzaisimao"
}