1.0.5 • Published 2 years ago

nuxt-cart-jy v1.0.5

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

require vue version >=2.7

Get Started

Set module in nuxt.config.js

modules: {
  ['nuxt-cart-jy', { options... }],
},

or

modules: {
  'nuxt-cart-jy',
},
cartCustom:{
  options...
}

With Typescript

// tsconfig.json

types:[
  "nuxt-cart-jy"
]

Usage

The module will record your cart data ,and auto calculate result after data was changed. It have some base properties , and you can custom your own properties.

API reference

When you use with this package, it will auto inject $cartCustom in your context

addItem(data:{id:string,price:number,quantity:number,src:string,discount?:number})

  • return:Void
  • Description:Add new items

editItem(id: string, data:{id:string,price:number,quantity:number,src:string,discount?:number})

  • return:Void
  • Description:Edit exist items by id

removeItem(id: string)

  • return:Void
  • Description:Remove exist items by id

setCart(key:string,value:any)

  • return:Void
  • Description:Set custom property

showCart()

  • return:Object
  • Description:Show full cart data

clearCart()

  • return:void
  • Description:Initial cart data

Options

cartFormat

  • Type:Object
  • Default:{ items: [], total: 0, quantity: 0 }
  • Description:You can set some custom preperties,and the default properties is required

ex:

wrong:

{
  //  without default properties
  time:'2022/08/02' //  custom property
}

right:

{
  // with default properties
  items: [],
  total: 0,
  quantity: 0,
  time:'2022/08/02' //  custom property
}

prefix

  • Type:String
  • Default:cartCustom_
  • Description: Prefix for cookies
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago