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

aspcms分类信息网站四川建设部官方网站

aspcms分类信息网站,四川建设部官方网站,手机网站打不开的解决方法,个人备案的网站可以做什么又来分享一点点工作积累及解决方案 产品中需要用户输入一些文字后按下回车键生成标签来显示在页面上&#xff0c;经过尝试与改造完成如下&#xff1a; <template><div class"tags-view" click"beginInput"><el-tag :key"index" …

又来分享一点点工作积累及解决方案

产品中需要用户输入一些文字后按下回车键生成标签来显示在页面上,经过尝试与改造完成如下:

<template><div class="tags-view" @click="beginInput"><el-tag :key="index" v-for="(tag, index) in dynamicTags" closable :disable-transitions="false"@close="handleClose(index)">{{ tag }}</el-tag><el-input v-if="inputVisible" class="input-new-tag" style="width: 100%;" v-model="inputValue" ref="saveTagInput"size="small" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm"></el-input><!-- <el-button v-else class="button-new-tag" size="small" @click="showInput">+</el-button> --></div>
</template><script>
export default {name: 'inputTag',props: {tags: {type: Array,default: []},},watch: {tags: {deep: true,immediate: true,handler(val) {this.dynamicTags = val || []}}},data() {return {dynamicTags: [],inputVisible: false,inputValue: ''};},methods: {handleClose(index) {this.dynamicTags.splice(index, 1);},showInput() {this.inputVisible = true;this.$nextTick(_ => {this.$refs.saveTagInput.$refs.input.focus();});},beginInput() {this.showInput();},handleInputConfirm() {let inputValue = this.inputValue;if (inputValue) {this.dynamicTags.push(inputValue);}const inputElement = this.$refs.saveTagInput.$refs.input; // 获取input DOM元素const isFocused = document.activeElement === inputElement; // 判断是否为当前焦点this.inputVisible = isFocused;this.inputValue = '';this.$emit('changed', this.dynamicTags)}}
}
</script><style lang="scss" scoped>
.tags-view {display: flex;flex-direction: row;justify-content: flex-start;align-items: center;flex-wrap: wrap;min-height: 32px;padding: 4px 5px;border: 1px solid #DCDFE6;border-radius: 4px;
}.button-new-tag {margin-left: 10px;height: 24px;line-height: 24px;padding-top: 0;padding-bottom: 0;
}.input-new-tag {height: 24px;line-height: 24px;width: 90px;//margin-left: 10px;vertical-align: bottom;
}::v-deep {.el-tag {margin-left: 5px;margin-top: 2px;margin-bottom: 2px;}.el-input__inner {height: 24px;line-height: 24px;border: none;padding: 0px 5px;}
}
</style>

组件的使用:

import InputTag from '../components/inputTag.vue'

tags用于默认值的回调,changed事件用于组件数据发生变化时的回调通知。 

<InputTag class="w-100" :tags="tagsValue" @changed="tagsChanged"></InputTag>

组件本身也比较简单,没有啥值得去细分和品评的技术点

enter事件和blur事件走了同一个事件,会导致输入不连续,为解决这个问题,我们只需要判断当前input是不是焦点,如果是,则不隐藏输入框即可,如下isFoucsed变量的判断即为是否本身自己是当前焦点的input!

handleInputConfirm() {let inputValue = this.inputValue;if (inputValue) {this.dynamicTags.push(inputValue);}const inputElement = this.$refs.saveTagInput.$refs.input; // 获取input DOM元素const isFocused = document.activeElement === inputElement; // 判断是否为当前焦点this.inputVisible = isFocused;this.inputValue = '';this.$emit('changed', this.dynamicTags)
}
http://www.yayakq.cn/news/51345/

相关文章:

  • 网站建设 软文发布三农网络公司排名
  • 做网站后台需要什么知识学编程的培训机构
  • 海南第六建设工程有限公司网站召唤神龙网页小游戏在线玩
  • 连云港网站建设开发vs2015 手机网站开发
  • 旅游网站开发价格怎么在手机上做网站
  • 沈阳制作网站建站天元建设集团有限公司财报
  • 做视频点播网站需要服务器存储吗校园网站建设网
  • 荣耀官方网站python基础教程电子书百度网盘
  • 做网站公司需要什么条件微信小程序制作软件免费
  • 商城建站系统wordpress 页面设置不了标签
  • 河南卓越建设工程有限公司网站南京网站建设推南京网站建设设计
  • 酒店微信网站建设企业网站建设解决方案
  • seo专业为网站建设免费制作企业宣传册制作工具
  • 上海网页制作与网站设小区媒体网站建设
  • 做钓鱼网站判刑七牛 wordpress插件
  • 山东省建设建设监理协会网站wordpress如何添加模板
  • 江苏建设人才考试网是啥网站东莞通
  • 北京建设主管部门网站怎么做原创动漫视频网站
  • 潍坊网站建设诸城高密网站开发pc端和手机端
  • 个人网站做企业备案关键词查询工具
  • 武冈网站建设廊坊手机网站制作
  • 网络网站建设的意义装修店铺设计
  • cdn如何做网站统计关于电子工程的学术论坛
  • 网站开发信息发布互联网营销方式有哪些
  • 建设银行贷款业务网站计算机网络网站建设的实训总结
  • 活动策划网站创建自己的个人网站
  • 如何在电商上购物网站咸宁网页设计
  • 建网站松滋哪家强?wordpress代码检查工具
  • 怎么做网站的关键词库做网站筹钱需要多少钱
  • 2018年做视频网站学生做义工网站