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

合伙做网站怎么分配股权优化网站推广排名

合伙做网站怎么分配股权,优化网站推广排名,企业网站维护建设项目实践报告,温州网站建设和推广文章目录 知识回顾前言源码分析1. ref2. 购物车案例分析3. 购物车计算、全选 拓展知识数据持久化localStorage 总结 知识回顾 前言 元素上使用 ref属性关联响应式数据&#xff0c;获取DOM元素 步骤 ● 创建 ref > const hRef ref(null) ● 模板中建立关联 > <h1 re…

文章目录

  • 知识回顾
  • 前言
  • 源码分析
    • 1. ref
    • 2. 购物车案例分析
    • 3. 购物车计算、全选
  • 拓展知识
    • 数据持久化localStorage
  • 总结


知识回顾

前言

元素上使用 ref属性关联响应式数据,获取DOM元素

步骤

● 创建 ref => const hRef = ref(null)
● 模板中建立关联 => <h1 ref="hRef">我是标题</h1>=> hRef.value

源码分析

1. ref

const inp = ref<null | HTMLInputElement>()
const img = ref<null | HTMLImageElement>()

vue

<script setup lang="ts">
import { onMounted, ref } from 'vue'const words = ref('')
const inp = ref<null | HTMLInputElement>()
const img = ref<null | HTMLImageElement>()
onMounted(() => {console.log('onMounted')inp.value?.focus()img.valueconsole.log(img.value)console.log(inp.value)
})
</script><template><div class="container" id="app"><div class="search-container"><img ref="img" src="https://" alt="" /><div class="search-box"><input ref="inp" type="text" v-model="words" id="inp" /><button>搜索一下</button></div></div></div>
</template><style>
html,
body {height: 100%;
}.search-container {position: absolute;top: 30%;left: 50%;transform: translate(-50%, -50%);text-align: center;
}.search-container .search-box {display: flex;
}.search-container img {margin-bottom: 30px;
}.search-container .search-box input {width: 512px;height: 16px;padding: 12px 16px;font-size: 16px;margin: 0;vertical-align: top;outline: 0;box-shadow: none;border-radius: 10px 0 0 10px;border: 2px solid #c4c7ce;background: #fff;color: #222;overflow: hidden;box-sizing: content-box;-webkit-tap-highlight-color: transparent;
}.search-container .search-box button {cursor: pointer;width: 112px;height: 44px;line-height: 41px;line-height: 42px;background-color: #ad2a27;border-radius: 0 10px 10px 0;font-size: 17px;box-shadow: none;font-weight: 400;border: 0;outline: 0;letter-spacing: normal;color: white;
}body {background: no-repeat center / cover;background-color: #edf0f5;
}
</style>

2. 购物车案例分析

列表渲染、购物车增加删除
css

.app-container {padding-bottom: 300px;width: 800px;margin: 0 auto;
}
@media screen and (max-width: 800px) {.app-container {width: 600px;}
}
.app-container .banner-box {border-radius: 20px;overflow: hidden;margin-bottom: 10px;
}
.app-container .banner-box img {width: 100%;
}
.app-container .nav-box {background: #ddedec;height: 60px;border-radius: 10px;padding-left: 20px;display: flex;align-items: center;
}
.app-container .nav-box .my-nav {display: inline-block;background: #5fca71;border-radius: 5px;width: 90px;height: 35px;color: white;text-align: center;line-height: 35px;margin-right: 10px;
}.breadcrumb {font-size: 16px;color: gray;
}
.table {width: 100%;text-align: left;border-radius: 2px 2px 0 0;border-collapse: separate;border-spacing: 0;
}
.th {color: rgba(0, 0, 0, 0.85);font-weight: 500;text-align: left;background: #fafafa;border-bottom: 1px solid #f0f0f0;transition: background 0.3s ease;
}
.th.num-th {flex: 1.5;
}
.th {text-align: center;
}
.th:nth-child(4),
.th:nth-child(5),
.th:nth-child(6),
.th:nth-child(7) {text-align: center;
}
.th.th-pic {flex: 1.3;
}
.th:nth-child(6) {flex: 1.3;
}.th,
.td {position: relative;padding: 16px 16px;overflow-wrap: break-word;flex: 1;
}
.pick-td {font-size: 14px;
}
.main,
.empty {border: 1px solid #f0f0f0;margin-top: 10px;
}
.tr {display: flex;cursor: pointer;border-bottom: 1px solid #ebeef5;
}
.tr.active {background-color: #f5f7fa;
}
.td {display: flex;justify-content: center;align-items: center;
}.table img {width: 100px;height: 100px;
}button {outline: 0;box-shadow: none;color: #fff;background: #d9363e;border-color: #d9363e;color: #fff;background: #d9363e;border-color: #d9363e;line-height: 1.5715;position: relative;display: inline-block;font-weight: 400;white-space: nowrap;text-align: center;background-image: none;border: 1px solid transparent;box-shadow: 0 2px 0 rgb(0 0 0 / 2%);cursor: pointer;transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;touch-action: manipulation;height: 32px;padding: 4px 15px;font-size: 14px;border-radius: 2px;
}
button.pay {background-color: #3f85ed;margin-left: 20px;
}.bottom {height: 60px;display: flex;align-items: center;justify-content: space-between;padding-right: 20px;border: 1px solid #f0f0f0;border-top: none;padding-left: 20px;
}
.right-box {display: flex;align-items: center;
}
.check-all {cursor: pointer;
}
.price {color: hotpink;font-size: 30px;font-weight: 700;
}
.price-box {display: flex;align-items: center;
}
.empty {padding: 20px;text-align: center;font-size: 30px;color: #909399;
}
.my-input-number {display: flex;
}
.my-input-number button {height: 40px;color: #333;border: 1px solid #dcdfe6;background-color: #f5f7fa;
}
.my-input-number button:disabled {cursor: not-allowed!important;
}
.my-input-number .my-input__inner {height: 40px;width: 50px;padding: 0;border: none;border-top: 1px solid #dcdfe6;border-bottom: 1px solid #dcdfe6;
}

vue

<script setup lang="ts">
import { ref } from 'vue'// 定义水果对象的类型
interface Fruit {id: numbericon: stringisChecked: booleannum: numberprice: number
}// 水果列表
const fruitList = ref<Fruit[]>([{id: 1,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/ll.png',isChecked: true,num: 2,price: 6},{id: 2,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/smt.png',isChecked: false,num: 7,price: 20},{id: 3,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/tg.png',isChecked: false,num: 3,price: 40},{id: 4,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/xg.png',isChecked: false,num: 10,price: 3},{id: 5,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/yl.png',isChecked: false,num: 20,price: 34}
])// 删除商品
const delGoods = (id: number) => {fruitList.value = fruitList.value.filter((item) => item.id !== id)
}
// 添加
const addGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num++
}
// 减少
const subGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num--
}
</script><template><div class="app-container" id="app"><!-- 顶部banner --><div class="banner-box"><img src="https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/sg_top.png" alt="" /></div><!-- 面包屑 --><div class="breadcrumb"><span>🏠</span>/<span>购物车</span></div><!-- 购物车主体 --><div v-if="fruitList.length > 0" class="main"><div class="table"><!-- 头部 --><div class="thead"><div class="tr"><div class="th">选中</div><div class="th th-pic">图片</div><div class="th">单价</div><div class="th num-th">个数</div><div class="th">小计</div><div class="th">操作</div></div></div><!-- 身体 --><div class="tbody"><divv-for="item in fruitList":key="item.id"class="tr":class="{ active: item.isChecked }"><div class="td"><input type="checkbox" v-model="item.isChecked" /></div><div class="td"><img :src="item.icon" alt="" /></div><div class="td">{{ item.price }}</div><div class="td"><div class="my-input-number"><button :disabled="item.num <= 1" class="decrease" @click="subGoods(item.id)">-</button><span class="my-input__inner">{{ item.num }}</span><button class="increase" @click="addGoods(item.id)">+</button></div></div><div class="td">{{ item.price * item.num }}</div><div class="td" @click="delGoods(item.id)"><button>删除</button></div></div></div></div><!-- 底部 --><div class="bottom"><!-- 全选 --><label class="check-all"><input type="checkbox" />全选</label><div class="right-box"><!-- 所有商品总价 --><span class="price-box">总价&nbsp;&nbsp;:&nbsp;&nbsp;¥&nbsp;<span class="price">24</span></span><!-- 结算按钮 --><button class="pay">结算( 6 )</button></div></div></div><!-- 空车 --><div v-else class="empty">🛒空空如也</div></div>
</template><style scoped>
@import './style/inputnumber.css';
@import './style/index.css';
</style>

3. 购物车计算、全选

<script setup lang="ts">
import { computed, ref } from 'vue'// 定义水果对象的类型
interface Fruit {id: numbericon: stringisChecked: booleannum: numberprice: number
}// 水果列表
const fruitList = ref<Fruit[]>([{id: 1,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/ll.png',isChecked: true,num: 2,price: 6},{id: 2,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/smt.png',isChecked: false,num: 7,price: 20},{id: 3,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/tg.png',isChecked: false,num: 3,price: 40},{id: 4,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/xg.png',isChecked: false,num: 10,price: 3},{id: 5,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/yl.png',isChecked: false,num: 20,price: 34}
])// 删除商品
const delGoods = (id: number) => {fruitList.value = fruitList.value.filter((item) => item.id !== id)
}
// 添加
const addGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num++
}
// 减少
const subGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num--
}// 全选
const checkAll = computed({get() {return fruitList.value.every((item) => item.isChecked)},set(value) {fruitList.value.forEach((item) => (item.isChecked = value))}
})// 统计选中的总数 reduce
const totalCount = computed(() => {return fruitList.value.reduce((sum, item) => {if (item.isChecked) {// 选中 → 需要累加return sum + item.num} else {// 没选中 → 不需要累加return sum}}, 0)
})// 总计选中的总价 num * price
const totalPrice = computed(() => {return fruitList.value.reduce((sum, item) => {if (item.isChecked) {return sum + item.num * item.price} else {return sum}}, 0)
})
</script><template><div class="app-container" id="app"><!-- 顶部banner --><div class="banner-box"><img src="https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/sg_top.png" alt="" /></div><!-- 面包屑 --><div class="breadcrumb"><span>🏠</span>/<span>购物车</span></div><!-- 购物车主体 --><div v-if="fruitList.length > 0" class="main"><div class="table"><!-- 头部 --><div class="thead"><div class="tr"><div class="th">选中</div><div class="th th-pic">图片</div><div class="th">单价</div><div class="th num-th">个数</div><div class="th">小计</div><div class="th">操作</div></div></div><!-- 身体 --><div class="tbody"><divv-for="item in fruitList":key="item.id"class="tr":class="{ active: item.isChecked }"><div class="td"><input type="checkbox" v-model="item.isChecked" /></div><div class="td"><img :src="item.icon" alt="" /></div><div class="td">{{ item.price }}</div><div class="td"><div class="my-input-number"><button :disabled="item.num <= 1" class="decrease" @click="subGoods(item.id)">-</button><span class="my-input__inner">{{ item.num }}</span><button class="increase" @click="addGoods(item.id)">+</button></div></div><div class="td">{{ item.price * item.num }}</div><div class="td" @click="delGoods(item.id)"><button>删除</button></div></div></div></div><!-- 底部 --><div class="bottom"><!-- 全选 --><label class="check-all"><input type="checkbox" v-model="checkAll" />全选</label><div class="right-box"><!-- 所有商品总价 --><span class="price-box">总价&nbsp;&nbsp;:&nbsp;&nbsp;¥&nbsp;<span class="price">{{ totalPrice }}</span></span><!-- 结算按钮 --><button class="pay">结算( {{ totalCount }} )</button></div></div></div><!-- 空车 --><div v-else class="empty">🛒空空如也</div></div>
</template><style scoped>
@import './style/inputnumber.css';
@import './style/index.css';
</style>

拓展知识

数据持久化localStorage

<script setup lang="ts">
import { computed, ref, watch } from 'vue'// 定义水果对象的类型
interface Fruit {id: numbericon: stringisChecked: booleannum: numberprice: number
}
const defaultData = [{id: 1,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/ll.png',isChecked: true,num: 2,price: 6},{id: 2,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/smt.png',isChecked: false,num: 7,price: 20},{id: 3,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/tg.png',isChecked: false,num: 3,price: 40},{id: 4,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/xg.png',isChecked: false,num: 10,price: 3},{id: 5,icon: 'https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/yl.png',isChecked: false,num: 20,price: 34}
]// 水果列表
let fruitList = ref<Fruit[]>(defaultData)
const localStorageFruitList = localStorage.getItem('fruitList')
if (localStorageFruitList && localStorageFruitList !== '[]') {fruitList.value = JSON.parse(localStorageFruitList)
}// 删除商品
const delGoods = (id: number) => {fruitList.value = fruitList.value.filter((item) => item.id !== id)
}
// 添加
const addGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num++
}
// 减少
const subGoods = (id: number) => {const fruit = fruitList.value.find((item) => item.id === id)fruit && fruit.num--
}// 全选
const checkAll = computed({get() {return fruitList.value.every((item) => item.isChecked)},set(value) {fruitList.value.forEach((item) => (item.isChecked = value))}
})// 统计选中的总数 reduce
const totalCount = computed(() => {return fruitList.value.reduce((sum, item) => {if (item.isChecked) {// 选中 → 需要累加return sum + item.num} else {// 没选中 → 不需要累加return sum}}, 0)
})// 总计选中的总价 num * price
const totalPrice = computed(() => {return fruitList.value.reduce((sum, item) => {if (item.isChecked) {return sum + item.num * item.price} else {return sum}}, 0)
})// 数据持久化方法
const saveData = () => {localStorage.setItem('fruitList', JSON.stringify(fruitList.value))
}
const getData = () => {const fruitListStr = localStorage.getItem('fruitList')
}
// 删除持久化
const delData = () => {localStorage.removeItem('fruitList')
}
// 清空持久化数据
const clearData = () => {localStorage.clear()
}
// 监听
watch(() => fruitList.value, saveData, { deep: true, immediate: true })
</script><template><div class="app-container" id="app"><!-- 顶部banner --><div class="banner-box"><img src="https://hongm-1312445828.cos.ap-nanjing.myqcloud.com/sg_top.png" alt="" /></div><!-- 面包屑 --><div class="breadcrumb"><span>🏠</span>/<span>购物车</span></div><!-- 购物车主体 --><div v-if="fruitList.length > 0" class="main"><div class="table"><!-- 头部 --><div class="thead"><div class="tr"><div class="th">选中</div><div class="th th-pic">图片</div><div class="th">单价</div><div class="th num-th">个数</div><div class="th">小计</div><div class="th">操作</div></div></div><!-- 身体 --><div class="tbody"><divv-for="item in fruitList":key="item.id"class="tr":class="{ active: item.isChecked }"><div class="td"><input type="checkbox" v-model="item.isChecked" /></div><div class="td"><img :src="item.icon" alt="" /></div><div class="td">{{ item.price }}</div><div class="td"><div class="my-input-number"><button :disabled="item.num <= 1" class="decrease" @click="subGoods(item.id)">-</button><span class="my-input__inner">{{ item.num }}</span><button class="increase" @click="addGoods(item.id)">+</button></div></div><div class="td">{{ item.price * item.num }}</div><div class="td" @click="delGoods(item.id)"><button>删除</button></div></div></div></div><!-- 底部 --><div class="bottom"><!-- 全选 --><label class="check-all"><input type="checkbox" v-model="checkAll" />全选</label><div class="right-box"><!-- 所有商品总价 --><span class="price-box">总价&nbsp;&nbsp;:&nbsp;&nbsp;¥&nbsp;<span class="price">{{ totalPrice }}</span></span><!-- 结算按钮 --><button class="pay">结算( {{ totalCount }} )</button></div></div></div><!-- 空车 --><div v-else class="empty">🛒空空如也</div></div>
</template><style scoped>
@import './style/inputnumber.css';
@import './style/index.css';
</style>

总结


文章转载自:
http://tuinal.kzrg.cn
http://antitheism.kzrg.cn
http://zeaxanthin.kzrg.cn
http://mzee.kzrg.cn
http://acetometer.kzrg.cn
http://pdry.kzrg.cn
http://polyalcohol.kzrg.cn
http://tbo.kzrg.cn
http://nonidentity.kzrg.cn
http://outbreed.kzrg.cn
http://sinisterly.kzrg.cn
http://disproportional.kzrg.cn
http://chummage.kzrg.cn
http://delegalize.kzrg.cn
http://stridden.kzrg.cn
http://maidenhood.kzrg.cn
http://canzone.kzrg.cn
http://linux.kzrg.cn
http://kaki.kzrg.cn
http://giltwood.kzrg.cn
http://sheriffalty.kzrg.cn
http://chasmy.kzrg.cn
http://clint.kzrg.cn
http://trenail.kzrg.cn
http://soddish.kzrg.cn
http://backstage.kzrg.cn
http://jumbotron.kzrg.cn
http://translatorese.kzrg.cn
http://trisepalous.kzrg.cn
http://moneychanging.kzrg.cn
http://nantua.kzrg.cn
http://zona.kzrg.cn
http://frosh.kzrg.cn
http://improvability.kzrg.cn
http://nauseate.kzrg.cn
http://humanely.kzrg.cn
http://oversight.kzrg.cn
http://shandite.kzrg.cn
http://panduriform.kzrg.cn
http://resident.kzrg.cn
http://ambilingual.kzrg.cn
http://anecdotalist.kzrg.cn
http://shoelace.kzrg.cn
http://heliograph.kzrg.cn
http://howl.kzrg.cn
http://viniculture.kzrg.cn
http://capsule.kzrg.cn
http://subshrub.kzrg.cn
http://plummet.kzrg.cn
http://psychoenergetic.kzrg.cn
http://underprize.kzrg.cn
http://amphitheatrical.kzrg.cn
http://clue.kzrg.cn
http://evidently.kzrg.cn
http://backslap.kzrg.cn
http://kyphosis.kzrg.cn
http://hagioscope.kzrg.cn
http://almond.kzrg.cn
http://potholder.kzrg.cn
http://fice.kzrg.cn
http://goldsmithry.kzrg.cn
http://univallate.kzrg.cn
http://anginal.kzrg.cn
http://sailer.kzrg.cn
http://flexuous.kzrg.cn
http://intermit.kzrg.cn
http://kolo.kzrg.cn
http://suiyuan.kzrg.cn
http://motorable.kzrg.cn
http://bicho.kzrg.cn
http://entomophilous.kzrg.cn
http://congery.kzrg.cn
http://thirteenth.kzrg.cn
http://verbicide.kzrg.cn
http://embosk.kzrg.cn
http://haliotis.kzrg.cn
http://preplan.kzrg.cn
http://airstream.kzrg.cn
http://odiously.kzrg.cn
http://scribe.kzrg.cn
http://hepatocarcinogen.kzrg.cn
http://vehiculum.kzrg.cn
http://exurb.kzrg.cn
http://definability.kzrg.cn
http://udt.kzrg.cn
http://herm.kzrg.cn
http://passant.kzrg.cn
http://inviolateness.kzrg.cn
http://zirconolite.kzrg.cn
http://extracurricular.kzrg.cn
http://brompton.kzrg.cn
http://anomaloscope.kzrg.cn
http://flightless.kzrg.cn
http://ultraclean.kzrg.cn
http://firebill.kzrg.cn
http://sustentacular.kzrg.cn
http://ichthyosaur.kzrg.cn
http://demonologic.kzrg.cn
http://chevroler.kzrg.cn
http://flexional.kzrg.cn
http://www.hrbkazy.com/news/86262.html

相关文章:

  • 微软手机做网站服务器营销策略都有哪些
  • 12306的网站建设如何制作一个自己的网页
  • 怎么进行网站优化有效的网络推广
  • 网站的数据库有什么用网站安全查询系统
  • 南通做百度网站的公司哪家好精准客源app
  • 网页制作与网站建设 论文湖南网站设计外包哪家好
  • 建网站都用什么字体sem搜索引擎
  • 清溪网站仿做好的推广方式
  • 小江高端网站建设镇江网站建设
  • 贵阳网站建设是什么意思郑州营销型网站建设
  • 沈阳网站建设成创简述搜索引擎的工作原理
  • 手把手教你做网站7百度小说排行榜第一名
  • wordpress论坛注册长沙seo服务
  • 建网站都要什么费用app投放推广
  • 免费ppt模板大全下载seo顾问阿亮
  • 重庆网站建设行业新闻邵阳seo优化
  • win8metro ui风格的wordpress南宁seo结算
  • 济南市建设监理有限公司网站营销培训总结
  • 广渠门网站建设广告软文范例大全100字
  • wordpress添加媒体无反应曹操论坛seo
  • 手机在线建站自己怎么免费做网站
  • 建设一个属于自己网站广州网络营销运营
  • 搭建商城哪家好怎么样百度点击优化
  • 网站要和别人做api 链接百度快速优化排名软件
  • 京东 推广网站怎么做常用的网络营销平台有哪些
  • 网络网站建设电话互联网推广员是做什么
  • 50款app软件免费下载青岛推广优化
  • 原创文章网站网站如何在百度刷排名
  • wordpress仿站方法关键词排名快速提升
  • 网站制作设计专业公司seo系统培训