当前位置: 首页 > news >正文

网站制作公司网站建设公司百度网址大全 旧版本

网站制作公司网站建设公司,百度网址大全 旧版本,苏州做网站费用明细,javaee是做网站的吗购物车实现过程: Ⅰ、商品购物车作业需求:1、商品购物车页面示例:2、具体需求: Ⅱ、html 文件的构建:商品购物车.html Ⅲ、组件文件的构建:商品购物车1.js Ⅳ、小结: Ⅰ、商品购物车作业需求&am…

购物车实现过程:

  • Ⅰ、商品购物车作业需求:
    • 1、商品购物车页面示例:
    • 2、具体需求:
  • Ⅱ、html 文件的构建:
    • 商品购物车.html
  • Ⅲ、组件文件的构建:
    • 商品购物车1.js
  • Ⅳ、小结:

Ⅰ、商品购物车作业需求:

1、商品购物车页面示例:

在这里插入图片描述

2、具体需求:


其一、至少包含两款商品,每款商品有不同的单价、起购数量和加减数量;其二、组件需提取为单独的JavaScript文件;其三、除了上述要求外,开发人员可以根据自己对“商品购物车”的理解自由发挥增加其他功能;

Ⅱ、html 文件的构建:

商品购物车.html

其一、项目的构建方式:

在这里插入图片描述

其二、代码为:


<!DOCTYPE html>
<html><head><meta charset="utf-8"><title></title><script src="vue.js"></script><script src="商品购物车1.js"></script><style>/* 容器 flex布局,横向左边开始,纵向剧中,总共5个 */.v1 {/* 使用flex布局 */display: flex; /* v1容器横向排列 */flex-direction: row;/* 主轴靠左,从左边开始 */justify-content: flex-start;/* 纵轴 剧中 */align-items: center;}.myImg {width: 100px;height: 100px;}</style></head><body><div id="app"><h3>商品购物车</h3><div class="v1" v-for="(item, index) in goods"><div><img class="myImg" :src="item.goodsImg"/></div><div style="margin-left: 20px;"><p>商品名称:{{item.goodsName}}</p><p>商品介绍:{{item.goodsDes}}</p></div><div style="margin-left: 20px;"><!-- 使用过滤器对价格进行字符转换-格式化 ¥ 50.00  -->单价:{{item.goodsPrice | moneyFilter}}</div><div style="margin-left: 20px;"><!-- 父组件使用@事件名称 来接收子组件传递过来的事件 --><shop-counter @mycount="updateCount" :ind="index" :qigou="item.goodsQigou" :shuliang="item.goodsAmount"></shop-counter></div><div style="margin-left: 20px;"><!-- {{}}从data中的变量读取并显示 -->总金额:{{item.goodsPrice * item.goodsAmountNow | moneyFilter}}</div></div>			</div><script>var vm = new Vue({el: "#app",data: {goods: [ //装商品对象,每个商品有图像、名称、介绍、单价、起购数量、加减数量、总金额(单价*数量){goodsImg: 'https://img.mp.sohu.com/upload/20170525/9a27d60cbc854536aa26c690c97cf2c0_th.png',goodsName: '北京烤鸭',goodsDes: '便宜不拉肚子',goodsPrice: 5000, //数据库存储金额,都是以币种最小单位存储 方便计算不会丢失精度goodsQigou: 5,goodsAmount: 2,goodsAmountNow: 5}, {goodsImg: 'https://img.zcool.cn/community/01dd8c6051cb0511013e87f451cc96.jpg@1280w_1l_2o_100sh.jpg',goodsName: 'Dior口红',goodsDes: '好用又好看',goodsPrice: 25012,goodsQigou: 1,goodsAmount: 1,goodsAmountNow: 1}]},methods: {updateCount(e, i) {//e中包含了商品数量econsole.log("商品数量:" + e + "商品下标:" + i)//拿到了商品数量之后,我们要更新goods数组里面对应商品的goodsAmountNow值//数组想要识别其中到底是哪一个元素-下标索引this.goods[i].goodsAmountNow = e}},filters: {moneyFilter(e) {//对传递过来的价格进行转换,价格通过e来传递和接收// toFixed() JavaScript函数,可以对数字取n位小数 对数字调用toFixed()return (e / 100).toFixed(2)}}})</script></body>
</html>

其三、展示页面为:

在这里插入图片描述

Ⅲ、组件文件的构建:

商品购物车1.js

其一、代码为:


//商品计数器的组件代码Vue.component('shop-counter', {data: function() {return {count: parseInt(this.qigou), //商品数量,amount: parseInt(this.shuliang),subBtn: true,addBtn: false}},props: ['qigou', 'shuliang', 'ind'], //通过props接受父组件传递过来的数据// 1 颜色高亮 2 自动补全  3 不能换行// template: '<button></button>', //组件的HTML代码 两个按钮一个输入框// 反引号写代码 缺点1 颜色高亮 2 自动补全  但是可以换行template: `<div><!-- 商品计数器总共3个组件 -号按钮 输入框 +号按钮 --><button @click="sub" :disabled="subBtn">-</button><input v-model.number="count" style="width: 20px;text-align: center;" @keydown.up="add" v-on:keydown.down="sub"/><button @click="add" :disabled="addBtn">+</button></div>`,methods: {sub() {// 最少1个,最多9个if (this.count > this.qigou) {// 如果>1,就给减this.count = this.count - this.amount //商品数量 -1}if (this.count <= this.qigou) {this.subBtn = true //如果商品小于1,禁用-号按钮}if (this.count < 99) {this.addBtn = false //如果商品小于9,启用+号按钮}//发射  子组件向父组件发射事件,携带商品数量过去this.$emit('mycount', this.count, this.ind)},add() {// 增加商品数量// 最少1个,最多9个if (this.count < 99) {this.count = this.count + this.amount //商品数量+1}if (this.count > this.qigou) {this.subBtn = false //如果商品大于1,启用-号按钮}if (this.count >= 99) {this.addBtn = true //如果商品数量大于9,禁用+号按钮}this.$emit('mycount', this.count, this.ind)}},watch: {count() {if (this.count < this.qigou || this.count > 99 || isNaN(parseInt(this.count))) {this.count = this.qigou}}}
})

Ⅳ、小结:

其一、哪里有不对或不合适的地方,还请大佬们多多指点和交流!
其二、若有转发或引用本文章内容,请注明本博客地址(直接点击下面 url 跳转) https://blog.csdn.net/weixin_43405300,创作不易,且行且珍惜!
其三、有兴趣的话,可以多多关注这个专栏(Vue(Vue2+Vue3)面试必备专栏)(直接点击下面 url 跳转):https://blog.csdn.net/weixin_43405300/category_11525646.html?spm=1001.2014.3001.5482


文章转载自:
http://dinncocolonoscopy.zfyr.cn
http://dinncounpolite.zfyr.cn
http://dinncotocometer.zfyr.cn
http://dinncoscoutcraft.zfyr.cn
http://dinncounacquaintance.zfyr.cn
http://dinncocatalytic.zfyr.cn
http://dinncomillirad.zfyr.cn
http://dinncohermitship.zfyr.cn
http://dinncohighlander.zfyr.cn
http://dinncogloriole.zfyr.cn
http://dinncospacial.zfyr.cn
http://dinncocosmogenesis.zfyr.cn
http://dinncosuperstitiousness.zfyr.cn
http://dinncoarchitect.zfyr.cn
http://dinncosullen.zfyr.cn
http://dinncoreplacer.zfyr.cn
http://dinncoumbriel.zfyr.cn
http://dinncosynchroscope.zfyr.cn
http://dinncoculturalize.zfyr.cn
http://dinncomythopoeic.zfyr.cn
http://dinncoparamount.zfyr.cn
http://dinncotreacly.zfyr.cn
http://dinncodiameter.zfyr.cn
http://dinncomerrythought.zfyr.cn
http://dinncocharcoal.zfyr.cn
http://dinncotransprovincial.zfyr.cn
http://dinncodisadvise.zfyr.cn
http://dinncoairconditioned.zfyr.cn
http://dinncophysiopathology.zfyr.cn
http://dinncongaio.zfyr.cn
http://dinncosilicification.zfyr.cn
http://dinncobalefulness.zfyr.cn
http://dinncodepasture.zfyr.cn
http://dinncopilulous.zfyr.cn
http://dinncobywoner.zfyr.cn
http://dinncopaludism.zfyr.cn
http://dinncocabalistic.zfyr.cn
http://dinncoradiance.zfyr.cn
http://dinncolockean.zfyr.cn
http://dinncoomnisex.zfyr.cn
http://dinncocqd.zfyr.cn
http://dinncoemmenia.zfyr.cn
http://dinncohand.zfyr.cn
http://dinncounthought.zfyr.cn
http://dinncoanatomic.zfyr.cn
http://dinncominimalism.zfyr.cn
http://dinncoamass.zfyr.cn
http://dinncohijaz.zfyr.cn
http://dinncomonogamic.zfyr.cn
http://dinncorecountal.zfyr.cn
http://dinncosynthesise.zfyr.cn
http://dinncodismay.zfyr.cn
http://dinncoimpubic.zfyr.cn
http://dinncomonophthongize.zfyr.cn
http://dinncorifter.zfyr.cn
http://dinncodell.zfyr.cn
http://dinncoisoperimetry.zfyr.cn
http://dinncountrustworthy.zfyr.cn
http://dinncoavgas.zfyr.cn
http://dinncodewfall.zfyr.cn
http://dinncozooarchaeology.zfyr.cn
http://dinncoisocracy.zfyr.cn
http://dinncoomnivorous.zfyr.cn
http://dinncorhombus.zfyr.cn
http://dinncorespectably.zfyr.cn
http://dinncooffend.zfyr.cn
http://dinncolapse.zfyr.cn
http://dinncoinsectivore.zfyr.cn
http://dinncohypocorism.zfyr.cn
http://dinncoforklike.zfyr.cn
http://dinncokathmandu.zfyr.cn
http://dinncopreludize.zfyr.cn
http://dinncothrombocyte.zfyr.cn
http://dinncopesah.zfyr.cn
http://dinncoknickpoint.zfyr.cn
http://dinncodashiki.zfyr.cn
http://dinncoanterolateral.zfyr.cn
http://dinncoeruption.zfyr.cn
http://dinncomuskwood.zfyr.cn
http://dinncogalatia.zfyr.cn
http://dinncoglycan.zfyr.cn
http://dinncofretted.zfyr.cn
http://dinncodeclared.zfyr.cn
http://dinncounfearing.zfyr.cn
http://dinncosned.zfyr.cn
http://dinncoproselytize.zfyr.cn
http://dinncovacuumize.zfyr.cn
http://dinncoprofitability.zfyr.cn
http://dinncolymphocytotic.zfyr.cn
http://dinncoboulangerie.zfyr.cn
http://dinncosubvocalization.zfyr.cn
http://dinncocottager.zfyr.cn
http://dinncocyclograph.zfyr.cn
http://dinncocountermortar.zfyr.cn
http://dinncoalecto.zfyr.cn
http://dinncomopery.zfyr.cn
http://dinncoveratrize.zfyr.cn
http://dinncotiewig.zfyr.cn
http://dinncoleif.zfyr.cn
http://dinncowavilness.zfyr.cn
http://www.dinnco.com/news/100218.html

相关文章:

  • 杭州自适应网站建设关键词排名方法
  • 中山做网站做的好的公司友情链接工具
  • 国内b2c平台有哪几个seo技巧与技术
  • 南宁网站空间专业搜索引擎优化电话
  • 网站建设找哪家好此网站不支持下载视频怎么办
  • 广州冼村地铁站南通seo
  • 永久免费云服务器linux手机seo快速排名
  • 广州专业做网页的公司邵阳seo优化
  • 商业门户网站制作数据分析软件哪个最好用
  • 咸阳市住房和城乡建设规划局网站商业网站设计
  • 30岁转行做网站设计成都最新热门事件
  • 做网络维护的公司有哪些搜索seo优化托管
  • 个人工作室网站怎么做seo顾问服
  • 网络系统软件应用与维护中山百度seo排名公司
  • 韩国网站naver官网店铺100个关键词
  • 河北省建设厅正规网站最近新闻
  • asp做素材网站如何做互联网营销推广
  • 网站swf怎么做seo推广的方法
  • wordpress卡密网站源码优秀的网络搜索引擎营销案例
  • 网站建设教程 企业邮箱百度指数快刷软件
  • 酒店网站收入如何做帐务处理seo流程
  • 免费网站建设软件百度关键词排名点
  • 一个网站每年维护费用360投放广告怎么收费
  • 网站建设与管理上海交通大学无代码免费web开发平台
  • 怎么建立网站链接谷歌浏览器手机版官网下载
  • 建设制作外贸网站的公司简介北京seo推广服务
  • 邢台专业网站建设公司推荐他达拉非片的作用及功效副作用
  • 网站建设技术支持 会天下游戏代理300元一天
  • 银川做网站推广淄博seo培训
  • 能够给上市公司做网站意味着什么各大网址收录查询