项目成果
项目演示地址:(腾讯云webify) supermale-5glmkgymb6d057cd-1301795258.ap-shanghai.app.tcloudbase.com
项目要点
- 1.在使用VueRouter进行页面跳转的时候,需要合理使用Vue生命周期的两个函数,activated函数与deactivated函数
- 2.Vue中使用better-Scroll的时候,等数据全部渲染完之后要重新调用refresh函数,重新计算内容的高度。
- 3.在使用Vuex时,将所有的操作全部放在actions中操作,mutations里面只进行单一操作。
- 4.Vuex中actions里面的方法可以使用Promise,在组件中通过dispatch发送事件的时候可以通过.then返回结果
addCart(context, product) {
return new Promise((resolve, reject) => {
let newProduct = context.state.cartList.find(item => item.iid == product.iid)
if(newProduct) {
context.commit('addCounter',newProduct)
resolve("商品数量+1")
} else {
product.count = 1
context.commit('addCar',product)
resolve("商品已添加至购物车")
}
})
}
- 5.组件之间的重复的代码操作可以通过混入,避免一些重复代码。
项目部署方式
devServer: {
disableHostCheck: true
}
- 3.腾讯云的webify(本文使用的这种方式【推荐】)
计费很便宜,几块钱能用很久
|