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

网站做等保备案搜狗推广登录入口

网站做等保备案,搜狗推广登录入口,网站建设与管理的发展,百度网页pc版登录又来分享一点点工作积累及解决方案 产品中需要用户输入一些文字后按下回车键生成标签来显示在页面上&#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.hkea.cn/news/741586/

相关文章:

  • 哪个网站做生鲜配送厦门seo外包公司
  • 水电行业公司设计logo重庆seo排名扣费
  • 可信赖的南昌网站制作站长工具网站
  • 济南建站公司电话成都关键词自然排名
  • 门户网站开发公司推广网页
  • 如何做网站认证实时军事热点
  • 上海的网站建设公司哪家好企业网站建设
  • 专业b2c电商网站制作网站推广要点
  • 现在的网站用什么程序做百度云官网登录入口
  • vs做网站怎样加数据库新闻小学生摘抄
  • 广州做网站mxszpt小说排行榜
  • 有什么网站是python做的网站营销策划公司
  • 长春有什么好的网站制作公司链接购买
  • 毕设网站佛山网站建设十年乐云seo
  • 北京做网站建设的公司哪家好手机怎么创建网站
  • winforms做网站注册百度账号
  • 玉泉路网站建设营销培训课程有哪些
  • 渭南做网站费用搜索引擎排名优化是什么意思
  • 做网站开发需要学什么软件微信公众平台开发
  • 网站整体营销方案网络营销的特点是什么?
  • 国内知名的网站建设公司有哪些百度指数专业版app
  • 画画外包网站如何推广一个网站
  • 互联网公司响应式网站深圳google推广
  • 深圳网站设计哪好什么推广平台比较好
  • 打开英文网站字体不对教程seo推广排名网站
  • 昭通市建设局网站太原百度关键词优化
  • 个人建网站允许吗seo职位要求
  • 环保网站设计网络营销优化推广
  • 网页设计网站制作公司冯耀宗seo视频教程
  • 怎么用路由器做网站百度指数平台官网