require vue version >=2.7
Set module in nuxt.config.js
modules: {
['nuxt-cart-jy', { options... }],
},
or
modules: {
'nuxt-cart-jy',
},
cartCustom:{
options...
}
// tsconfig.json
types:[
"nuxt-cart-jy"
]
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.
When you use with this package, it will auto inject $cartCustom in your context
- return:
Void - Description:Add new items
- return:
Void - Description:Edit exist items by
id
- return:
Void - Description:Remove exist items by
id
- return:
Void - Description:Set custom property
- return:
Object - Description:Show full cart data
- return:
void - Description:Initial cart data
- 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
}
- Type:
String - Default:
cartCustom_ - Description: Prefix for cookies