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

网站分析如何在其他平台做推广

网站分析,如何在其他平台做推广,建设部网站官工程质量手册,晋中网站建设公司这段HTML代码实现了一个简单的购物车实战小项目的前端页面,结合了Vue.js框架来实现数据响应式和交互逻辑。页面展示了购物车中的商品项,每个商品项有增减数量的按钮,并且能显示商品总数以及目前固定为0元的商品总价和总价计算。 【运用响应式…

 

        这段HTML代码实现了一个简单的购物车实战小项目的前端页面,结合了Vue.js框架来实现数据响应式和交互逻辑。页面展示了购物车中的商品项,每个商品项有增减数量的按钮,并且能显示商品总数以及目前固定为0元的商品总价和总价计算。 【运用响应式数据内容】

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>实战小项目:购物车</title><style>body {font-family: Arial, sans-serif;}.cart-item {width: 50%;margin-bottom: 15px;padding: 10px;border: 2px solid gray;border-radius: 10px;background-color: #ddd;}.buttons {margin-top: 5px;}.buttons button {padding: 5px 10px;margin-right: 5px;font-size: 16px;cursor: pointer;border: none;border-radius: 3px;background-color: pink;}.buttons input {width: 25px;}.buttons button:hover {background-color: yellow;}.quantity {font-size: 18px;font-weight: bold;margin-left: 10px;}h1, h2 {color: #333;}</style>
</head>
<body><div id="app"><h1>实战小项目:购物车</h1><!-- 提示:可以使用v-for指令,假设有n个品类,则生成n个商品项--><div class="cart-item" v-for="(item, index) in cartItems"><div class="buttons"><span>{{item.name}} &nbsp;&nbsp;</span><button v-on:click = "decreaseQuantity(index)">-</button><span class="quantity">{{ cartItems[index].quantity }}&nbsp;&nbsp;</span><button v-on:click = "increaseQuantity(index)">+</button><p>请输入价格:<input type="text" v-model="cartItems[index].unit_price"/> 元/斤 <br> 单价:{{cartItems[index].unit_price}} 元/斤</p></div></div><!-- 提示:可以用计算属性或数据变动侦听器,跟踪商品数和单价的变化,进而求出总数和总价--><h3>商品总数:  <ins> {{totalItems}} </ins> 件</h3><h3>商品总价:  <ins> {{sum}}</ins> 元</h3></div><script type="module">import { createApp, reactive, computed } from './vue.esm-browser.js'createApp({setup() {// 1.定义属性:存储商品的(响应式)数组 const cartItems = reactive([{ name: '苹果', quantity: 0, unit_price: "" },{ name: '香蕉', quantity: 0, unit_price: "" },{ name: '菠萝', quantity: 0, unit_price: "" },// 可以自适应添加更多商品 // { name: '芒果', quantity: 0, unit_price: "" },// { name: '鸭梨', quantity: 0, unit_price: "" },]);// 2.定义方法:增加商品数// increaseQuantity方法:以一个商品在cartItems数组中的索引为参数const increaseQuantity = (index) => {// 点击"+"时,商品数量+1cartItems[index].quantity += 1;  }// 3.定义方法:减少商品数const decreaseQuantity = (index) => {// 商品数量没有负值,因此多加一道判断// 商品数量小于0时,不会-1if(cartItems[index].quantity > 0){// 点击"-"时,商品数量-1cartItems[index].quantity -= 1;}}// 4.定义方法:计算商品总数// totalItems计算属性const totalItems = computed(() => {let total_items = 0;// 遍历cartItems数组,计算每个商品的数量for(const item of cartItems){// 累加在一起total_items += item.quantity;}return total_items})// 5.定义方法:计算商品总价const sum = computed(() =>{let total_sum=0;for(const item of cartItems){// 商品总价=商品数量*商品单价total_sum+=item.quantity*item.unit_price;}return total_sum})// 6.暴露属性和方法return {cartItems, increaseQuantity,decreaseQuantity,totalItems,sum};},}).mount('#app');</script>
</body>
</html>

http://www.hrbkazy.com/news/33686.html

相关文章:

  • 用vs2010做免费网站模板seo推广怎么学
  • 国外网站建设视频教学浙江百度推广
  • 花钱做网站注意些什么南宁市优化网站公司
  • 广州哪里做网站南京百度关键字优化价格
  • 合肥网站优化价格营销型网站建设论文
  • 外包公司好不好百度seo还有前景吗
  • 创建网站快捷方式到桌面百度seo提高排名费用
  • 广州搬家公司云速seo百度点击
  • 设计相关网站重庆seo推广外包
  • 佛山网站建设联系电话百度云群组
  • 阜阳网站优化北京网站seo优化推广
  • php户外运动产品企业网站源码网盟推广平台
  • 优秀界面设计作品沈阳seo公司
  • 电子商务网站建设利益分析营销推广方式
  • 本地网站做哪方面吸引人查询网站流量
  • 网站建设公司优惠大酬宾活动网店推广策略
  • 做摄影的网站知乎优化技术
  • 深圳沙井公司网站建设seo免费自学的网站
  • 做网站哪里找十大经典事件营销案例
  • 焦作网站制作长沙seo招聘
  • 怎样建设自己的ip地址网站企业网站建设多少钱
  • 网络营销的实现方式有哪些关键词排名优化流程
  • 长沙移动网站建设衡阳seo服务
  • 阿里云服务器建设网站选择那个镜像信息流优化师培训机构
  • 奉贤武汉阳网站建设百度seo2022新算法更新
  • 代理服务器地址和端口是多少seo托管
  • 网站可以用cdr做吗推广方案有哪些
  • 网站建设业务的途径的体会西安seo整站优化
  • 沈阳建设公司网站徐州seo建站
  • 寿宁建设局网站郑州网络推广哪个好