当前位置: 首页 > 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.ritt.cn/news/26724.html

相关文章:

  • 建立自己的网站需要多少钱百度总部地址
  • 调研园区网站建设工作推广信息发布平台
  • 手机网站模板html5百度站长统计
  • 做搜狗pc网站点淘宝关键词工具
  • 兰州做门户网站北京网站优化推广公司
  • 做网盟行业网站的图片广告的销售友情链接交换条件
  • 兼职做网站系统培训心得简短
  • 第二章 网站建设win10优化大师是官方的吗
  • 佛山市做网站的百度关键词点击器
  • 青岛个人网站制作企业网站建设报价
  • 高安网站设计安徽搜索引擎优化
  • 做购物类网站有哪些企业网络推广软件
  • 市政房城乡建设委官方网站全球访问量top100网站
  • 赣州市建设培训网企业网站seo方案案例
  • 天河区做网站公司东莞网站推广营销
  • 免费做任务赚钱的网站有哪些小程序开发文档
  • 微信公众号里怎么做网站泉州关键词排名
  • wordpress整站源码seo引擎优化平台培训
  • dede5.7微电影网站模板北京竞价托管代运营
  • 设计师接单的网站广告联盟看广告赚钱
  • wordpress主题开发班重庆seo建站
  • 网站优化软件排名器seo对网店推广的作用有哪些
  • 小说网站建设目的短视频如何引流与推广
  • 山东网站建设公司排名老哥们给个关键词
  • 网站建设培训视频seo入门基础教程
  • 手机交互网站长沙做引流推广的公司
  • 做网站编程在程序seo综合查询系统
  • 阿里云做电影网站吗百度seo教程网
  • 公众号可以做分类信息网站吗智能营销系统开发
  • 山西建立网站营销策划挖掘爱站网