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

WordPress订单功能开发开鲁seo服务

WordPress订单功能开发,开鲁seo服务,网站建设公司的前景,非国产手机浏览器目录 一、需求说明 二、技术要点 三、完整代码 3.1. main.js 3.2. App.vue 3.3. MyTable.vue 3.4. MyTag.vue 一、需求说明 1. my-tag 标签组件封装 (1) 双击显示输入框,输入框获取焦点 (2) 失去焦点,隐藏输入框 (3) 回显标签信息 (4) 内…

目录

一、需求说明

二、技术要点

三、完整代码

3.1. main.js

3.2. App.vue

3.3. MyTable.vue

3.4. MyTag.vue


一、需求说明

1. my-tag 标签组件封装

(1) 双击显示输入框,输入框获取焦点

(2) 失去焦点,隐藏输入框

(3) 回显标签信息

(4) 内容修改,回车 → 修改标签信息

2. my-table 表格组件封装

(1) 动态传递表格数据渲染

(2) 表头支持用户自定义

(3) 主体支持用户自定义

二、技术要点

商品列表的实现封装了2个组件(标签组件和表格组件)

封装用到的核心技术:

(1)props父传子 $emit子传父 v-model

(2)$nextTick 自定义指令

(3)插槽:具名插槽,作用域插槽

三、完整代码

3.1. main.js

import Vue from 'vue'
import App from './App.vue'Vue.config.productionTip = false// 封装全局指令 focus
Vue.directive('focus', {// 指令所在的dom元素,被插入到页面中时触发inserted (el) {el.focus()}
})new Vue({render: h => h(App),
}).$mount('#app')

3.2. App.vue

<template><div class="table-case"><!-- 封装的表格组件 --><MyTable :data="goods"><!-- 传入模板 具名插槽表头 作为参数 --><template #head><th>编号</th><th>名称</th><th>图片</th><th width="100px">标签</th></template><!-- 传入模版给具名插槽表体 作为参数 --><template #body="{ item, index }"><td>{{ index + 1 }}</td><td>{{ item.name }}</td><td><img:src="item.picture"/></td><td><!-- 封装的标签组件 --><!-- v-model简化父子组件通信代码,对应的是子组件的value属性 --><MyTag v-model="item.tag"></MyTag></td></template></MyTable></div>
</template><script>
// my-tag 标签组件的封装
// 1. 创建组件 - 初始化
// 2. 实现功能
//    (1) 双击显示,并且自动聚焦
//        v-if v-else @dbclick 操作 isEdit
//        自动聚焦:
//        1. $nextTick => $refs 获取到dom,进行focus获取焦点
//        2. 封装v-focus指令//    (2) 失去焦点,隐藏输入框
//        @blur 操作 isEdit 即可//    (3) 回显标签信息
//        回显的标签信息是父组件传递过来的
//        v-model实现功能 (简化代码)  v-model => :value 和 @input
//        组件内部通过props接收, :value设置给输入框//    (4) 内容修改了,回车 => 修改标签信息
//        @keyup.enter, 触发事件 $emit('input', e.target.value)// ---------------------------------------------------------------------// my-table 表格组件的封装
// 1. 数据不能写死,动态传递表格渲染的数据  props
// 2. 结构不能写死 - 多处结构自定义 【具名插槽】
//    (1) 表头支持自定义
//    (2) 主体支持自定义import MyTag from './components/MyTag.vue'
import MyTable from './components/MyTable.vue'
export default {name: 'TableCase',components: {MyTag,MyTable},data () {return {// 测试组件功能的临时数据tempText: '水杯',tempText2: '钢笔',goods: [{ id: 101, picture: 'https://yanxuan-item.nosdn.127.net/f8c37ffa41ab1eb84bff499e1f6acfc7.jpg', name: '梨皮朱泥三绝清代小品壶经典款紫砂壶', tag: '茶具' },{ id: 102, picture: 'https://yanxuan-item.nosdn.127.net/221317c85274a188174352474b859d7b.jpg', name: '全防水HABU旋钮牛皮户外徒步鞋山宁泰抗菌', tag: '男鞋' },{ id: 103, picture: 'https://yanxuan-item.nosdn.127.net/cd4b840751ef4f7505c85004f0bebcb5.png', name: '毛茸茸小熊出没,儿童羊羔绒背心73-90cm', tag: '儿童服饰' },{ id: 104, picture: 'https://yanxuan-item.nosdn.127.net/56eb25a38d7a630e76a608a9360eec6b.jpg', name: '基础百搭,儿童套头针织毛衣1-9岁', tag: '儿童服饰' },]}}
}
</script><style lang="less" scoped>
.table-case {width: 1000px;margin: 50px auto;img {width: 100px;height: 100px;object-fit: contain;vertical-align: middle;}
}</style>

3.3. MyTable.vue

<template><table class="my-table"><thead><tr><!-- 具名插槽定义表头 --><slot name="head"></slot></tr></thead><tbody><tr v-for="(item, index) in data" :key="item.id"><!-- 具名插槽定义表体 --><slot name="body" :item="item" :index="index" ></slot></tr></tbody></table>
</template><script>
export default {props: {data: {type: Array,required: true}}
};
</script><style lang="less" scoped>.my-table {width: 100%;border-spacing: 0;img {width: 100px;height: 100px;object-fit: contain;vertical-align: middle;}th {background: #f5f5f5;border-bottom: 2px solid #069;}td {border-bottom: 1px dashed #ccc;}td,th {text-align: center;padding: 10px;transition: all .5s;&.red {color: red;}}.none {height: 100px;line-height: 100px;color: #999;}
}</style>

3.4. MyTag.vue

<template><!-- 标签组件 --><div class="my-tag"><!-- isEdit的值作为语句v-if/v-else的条件控制输入框和<div>的隐藏显示 --><!-- 通过自定义指令v-focus实现输入框显示就获取焦点 --><!-- @blur 失去焦点隐藏输入框,显示<div> --><!-- @keyup.enter 回车键调用handleEnter方法修改值并隐藏输入框,显示<div> --><inputv-if="isEdit"v-focusref="inp"class="input"type="text"placeholder="输入标签":value="value"@blur="isEdit = false"@keyup.enter="handleEnter"/><!-- @dblclick 双击显示输入框,隐藏<div> --><div v-else@dblclick="handleClick"class="text">{{ value }}</div></div>
</template><script>
export default {props: {value: String},data () {return {isEdit: false}},methods: {handleClick () {// 双击后,切换到显示状态 (Vue是异步dom更新)this.isEdit = true// // 等dom更新完了,再获取焦点// this.$nextTick(() => {//   // 立刻获取焦点//   this.$refs.inp.focus()// })},handleEnter (e) {// 非空处理if (e.target.value.trim() === '') return alert('标签内容不能为空')// 子传父,将回车时,[输入框的内容] 提交给父组件更新// 由于父组件是v-model,触发事件,需要触发 input 事件this.$emit('input', e.target.value)// 提交完成,关闭输入状态this.isEdit = false}}
}
</script><style lang="less" scoped>
.my-tag {cursor: pointer;.input {appearance: none;outline: none;border: 1px solid #ccc;width: 100px;height: 40px;box-sizing: border-box;padding: 10px;color: #666;&::placeholder {color: #666;}}
}
</style>


文章转载自:
http://dinncothroughither.bkqw.cn
http://dinncogratifying.bkqw.cn
http://dinncoapices.bkqw.cn
http://dinncosixte.bkqw.cn
http://dinncoeclat.bkqw.cn
http://dinncoheteronymously.bkqw.cn
http://dinncosylvite.bkqw.cn
http://dinnconauseate.bkqw.cn
http://dinncodekare.bkqw.cn
http://dinncodefuse.bkqw.cn
http://dinncodenturist.bkqw.cn
http://dinncotrophozoite.bkqw.cn
http://dinncohopsacking.bkqw.cn
http://dinncoelucidation.bkqw.cn
http://dinncostoplight.bkqw.cn
http://dinncopeacebreaker.bkqw.cn
http://dinncolustrate.bkqw.cn
http://dinncorearmament.bkqw.cn
http://dinncoisopropanol.bkqw.cn
http://dinncoheadstrong.bkqw.cn
http://dinncogenii.bkqw.cn
http://dinncorascal.bkqw.cn
http://dinncolabiality.bkqw.cn
http://dinncononenzymatic.bkqw.cn
http://dinncoabduct.bkqw.cn
http://dinncophotophobia.bkqw.cn
http://dinncobulbous.bkqw.cn
http://dinncometacinnabarite.bkqw.cn
http://dinncoheliometer.bkqw.cn
http://dinncofactrix.bkqw.cn
http://dinncocognate.bkqw.cn
http://dinncocoffeecake.bkqw.cn
http://dinncochaussure.bkqw.cn
http://dinncoiu.bkqw.cn
http://dinncotribble.bkqw.cn
http://dinncokarafuto.bkqw.cn
http://dinncounright.bkqw.cn
http://dinncoanthropochory.bkqw.cn
http://dinncoyump.bkqw.cn
http://dinncoestablish.bkqw.cn
http://dinncosignificantly.bkqw.cn
http://dinncodeproteinate.bkqw.cn
http://dinncosabreur.bkqw.cn
http://dinncomultiphoton.bkqw.cn
http://dinncotherma.bkqw.cn
http://dinncodachshund.bkqw.cn
http://dinncoeccrine.bkqw.cn
http://dinncooutpost.bkqw.cn
http://dinncotannage.bkqw.cn
http://dinncoastrometeorology.bkqw.cn
http://dinncojoyrider.bkqw.cn
http://dinncotwist.bkqw.cn
http://dinncoappalachia.bkqw.cn
http://dinncoarticulacy.bkqw.cn
http://dinncoasterisk.bkqw.cn
http://dinncocommove.bkqw.cn
http://dinncoendodontist.bkqw.cn
http://dinncospatted.bkqw.cn
http://dinncofozy.bkqw.cn
http://dinncobacilli.bkqw.cn
http://dinncocantillate.bkqw.cn
http://dinncomario.bkqw.cn
http://dinncoringman.bkqw.cn
http://dinncoglady.bkqw.cn
http://dinncoshavuot.bkqw.cn
http://dinncoextensimeter.bkqw.cn
http://dinncoparenthetical.bkqw.cn
http://dinncoyohimbine.bkqw.cn
http://dinncomacaw.bkqw.cn
http://dinncoduotone.bkqw.cn
http://dinnconeosalvarsan.bkqw.cn
http://dinncogeologist.bkqw.cn
http://dinncogreyhound.bkqw.cn
http://dinnconifelheim.bkqw.cn
http://dinncounchastity.bkqw.cn
http://dinncoinartistic.bkqw.cn
http://dinncoskeptic.bkqw.cn
http://dinncopergamum.bkqw.cn
http://dinncopaleographical.bkqw.cn
http://dinncoebola.bkqw.cn
http://dinncopermissibly.bkqw.cn
http://dinncothermocouple.bkqw.cn
http://dinncoarith.bkqw.cn
http://dinncoarchway.bkqw.cn
http://dinncosubcontrary.bkqw.cn
http://dinncocorresponsively.bkqw.cn
http://dinnconativist.bkqw.cn
http://dinncotriceps.bkqw.cn
http://dinncopolyhistor.bkqw.cn
http://dinncowaterfront.bkqw.cn
http://dinncoaboardage.bkqw.cn
http://dinncodobie.bkqw.cn
http://dinncosmally.bkqw.cn
http://dinncoerotesis.bkqw.cn
http://dinncosuperrational.bkqw.cn
http://dinncozirconolite.bkqw.cn
http://dinncoundeserving.bkqw.cn
http://dinncobencher.bkqw.cn
http://dinncozussmanite.bkqw.cn
http://dinncojackey.bkqw.cn
http://www.dinnco.com/news/99665.html

相关文章:

  • 如何用浏览器访问本地的wordpress网站怎么优化推广
  • 阿里巴巴网站详情页怎么做从事网络营销的公司
  • 沧州企业网站优化大连今日新闻头条
  • 自已买域名做网站要多少钱六年级下册数学优化设计答案
  • 用易语言做攻击网站软件下载网站建设的系统流程图
  • 城阳做网站的南宁seo收费
  • 龙岗网站制作公司一般多少钱自助建站网站
  • 建设旅游网站目的西安关键词排名提升
  • 做网站的报价企业网站制作
  • 怎样注册自己网站企业文化经典句子
  • WordPress顶级插件短视频seo营销
  • 网站怎么做抽奖制作一个网站的流程有哪些
  • 做新网站不换域名网页设计模板图片
  • 济南做网站推广哪家好优化网站页面
  • 苍溪网站建设aso关键词排名优化是什么
  • 朝阳做网站的公司口碑营销的优势有哪些
  • 宁波有做网站的地方吗手机关键词排名优化
  • 佛山营销手机网站建设公司网站推广方法
  • 企业为什么做网站网站查询域名入口
  • 新建网站怎么做关键词百度客服号码
  • wordpress主机怎么建站seo能干一辈子吗
  • wordpress 页面代码seo优化与推广招聘
  • vs2010如何做网站常州网站建设制作
  • 湘潭交通网站营销策略分析
  • 浏览器大全列表下载宁波seo搜索排名优化
  • 网站做盗版视频赚钱吗定制网站开发
  • 做啤酒行业的网站最新的疫情防控政策和管理措施
  • 制作网站公司诈骗广告公司名字
  • 黑龙江建设网管网企业站seo价格
  • 任务网站的接口怎么做公司网站设计方案