Giter Club home page Giter Club logo

custom-cart's Introduction

custom-cart### 1.安装计算属性

npm install --save miniprogram-computed
构建npm

2.封装即可

​ 参考资源源码

3.参数

参数 默认值 是否必须 说明
products 购物车数据
bindsubmit 结算提交事件
binddelete 删除购物车事件

4.请求数据格式

products 数据中,对象内的元素字段必须是当前效果,如果要修改,需要对源码自行修改

 products:[{
  // 商品数据格式,源码可根据实际情况更改
  id:2,
  goodsname:"苹果手机",
  goodspic:"/pages/cart/1.jpg",
  num:2,
  price:2000,
  checked:true
 }]
 

5.事件返回数据

bindsubmit 事件

detail为购物车提交事件,返回的总价钱及总数量

type: "submit"
timeStamp: 6139
target: {id: "", dataset: {}}
currentTarget: {id: "", dataset: {}}
mark: {}
detail: {totalPrice: 5000, totalNum: 3}    // 自定义返回数据
touches: undefined
changedTouches: undefined
mut: false
_requireActive: undefined

bindDelete事件

detail为购物车删除事件,返回的是当前删除数据的id和索引位置

type: "delete"
timeStamp: 16480
target: {id: "", dataset: {}}
currentTarget: {id: "", dataset: {}}
mark: {}
detail: {id: 1, index: 0}  // 自定义返回数据
touches: undefined
changedTouches: undefined
mut: false
_requireActive: undefined

custom-cart's People

Contributors

zhaoweidongsundi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.