首页 > 其他分享 >拖拽和切换

拖拽和切换

时间:2023-03-05 23:34:53浏览次数:41  
标签:src name text 88 tag 切换 https 拖拽

  1 <template>
  2   <!-- 拖拽功能 -->
  3   <div class="dragBox">
  4     <draggable v-model="list" tag="transition-group" group="list" animation="300">
  5       <transition-group class="transTag">
  6         <el-tag closable @click="tagClick(tag)" @close="handleClose(tag)" v-for="(tag, index) of list" :key="index">
  7           <div v-if="tag.type === 'text'">{{ tag.text }}</div>
  8           <el-avatar v-else :size="20" :src="tag.src">
  9             {{ tag.src === '' ? '' : 'user' }}
 10           </el-avatar>
 11         </el-tag>
 12       </transition-group>
 13     </draggable>
 14 
 15     <el-dropdown trigger="click" ref="dropdownRef" @command="dropDownBtn">
 16       <span class="el-dropdown-link">
 17         <el-button size="small" @click="showInput">+</el-button>
 18       </span>
 19       <template #dropdown>
 20         <el-dropdown-menu>
 21           <el-dropdown-item command="图标">图标</el-dropdown-item>
 22           <el-dropdown-item command="文本">文本</el-dropdown-item>
 23         </el-dropdown-menu>
 24       </template>
 25     </el-dropdown>
 26 
 27     <!-- 选择图标或者文本的容器 -->
 28     <div class="selectContent">
 29       <!-- 文本 -->
 30       <el-collapse v-model="activeNames" v-if="tagType === 'text'">
 31         <el-collapse-item title="自定义列文本" name="1">
 32           <div class="selectClass">
 33             <el-select v-model="textTypeSelect">
 34               <el-option label="时间" value="time"></el-option>
 35               <el-option label="时间" value="time"></el-option>
 36             </el-select>
 37             <div>类型滚动占位</div>
 38           </div>
 39           <div class="searchClass">
 40             <el-input placeholder="搜索">
 41               <template #suffix>
 42                 <el-icon class="el-input__icon">
 43                   <Search />
 44                 </el-icon>
 45               </template>
 46             </el-input>
 47             <el-input type="textarea" class="contentClass" v-model="textContent">
 48             </el-input>
 49           </div>
 50         </el-collapse-item>
 51       </el-collapse>
 52 
 53       <!-- icon -->
 54       <el-collapse class="collapse" v-model="activeNames" v-else>
 55         <el-collapse-item title="替换图标" name="1">
 56           <div class="inputClass">
 57             <el-select v-model="iconTypeSelect">
 58               <el-option label="头像" value="ava"></el-option>
 59             </el-select>
 60             <el-input placeholder="搜索">
 61               <template #suffix>
 62                 <el-icon class="el-input__icon">
 63                   <Search />
 64                 </el-icon>
 65               </template>
 66             </el-input>
 67           </div>
 68           <div class="iconContentClass">
 69             <el-avatar v-for="(tag, i) of avaList" :size="40" :src="tag.src" :key="i"></el-avatar>
 70           </div>
 71         </el-collapse-item>
 72       </el-collapse>
 73 
 74     </div>
 75   </div>
 76 </template>
 77 <script>
 78 import { createVNode } from 'vue'
 79 import { VueDraggableNext } from 'vue-draggable-next'
 80 import { Search, Edit, Check, Message, Star, Delete, } from "@element-plus/icons";
 81 export default {
 82   components: {
 83     draggable: VueDraggableNext, Search
 84   },
 85   data() {
 86     return {
 87       avaList: [
 88         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 89         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 90         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 91         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 92         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 93         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 94         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 95         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 96         { src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png', name: 'user' },
 97       ],
 98       inputValue: '',
 99       inputVisible: false,
100       list: [
101         { text: '文本1', type: 'text' },
102         { text: '文本2', type: 'text' },
103         { text: 'icon1', type: 'icon', src: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png' },
104       ],
105       tableHead: [
106         { label: '姓名', prop: 'name' },
107         { label: '年龄', prop: 'age' },
108       ],
109       tableData: [
110         { name: '张三', age: 12 },
111         { name: '李四', age: 12 },
112       ],
113       activeNames: 1,
114       textTypeSelect: '',
115       iconTypeSelect: 'ava',
116       tagType: 'text',
117       textContent: '',
118     }
119   },
120   methods: {
121     onEnd(e) {
122       console.log(e)
123     },
124     // 点击选项 占位的内容
125     dropDownBtn(val) {
126       if (val === '文本') {
127         // 文本
128         this.list.push({ text: '文本', type: 'text' })
129       } else {
130         // 图标
131         this.list.push({ text: 'icon', type: 'icon' })
132       }
133     },
134     // 弹出选择 文本/icon 选择框
135     showInput(e) {
136       console.log(e)
137       this.$nextTick(() => {
138         this.$refs.dropdownRef.handleOpen()
139       })
140     },
141     // 点击tag 切换内容下面选择
142     tagClick(tag) {
143       console.log(tag.type);
144       this.textContent = tag.text
145       this.tagType = tag.type
146     },
147     // 删除tag
148     handleClose(tag) {
149       let index = this.list.map(item => item.text).indexOf(tag.text)
150       this.list.splice(index, 1)
151     },
152     // 删除tag 头像
153     handletagClose(tag) {
154       console.log(tag)
155       tag.src = ''
156       // this.tagList.splice(this.tagList.indexOf(tag.src), 1)
157     },
158   }
159 }
160 </script>
161   
162 <style scoped>
163 .read-the-docs {
164   color: #888;
165 }
166 
167 .dragBox {
168   width: 500px;
169   height: 500px;
170   border: 1px solid red;
171   /* display: flex;
172   flex-direction: column;
173   justify-content: flex-start;
174   align-items: center; */
175 }
176 
177 .el-tag {
178   margin: 0 10px;
179 }
180 
181 .dragBox>>>.el-dropdown {
182   width: 10px;
183   height: 10px;
184 }
185 
186 .dragBox>>>.el-button {
187   width: 25px;
188   height: 25px;
189   border-radius: 20px;
190   margin-top: 2px;
191 }
192 
193 .selectContent {
194   width: 100%;
195   height: 300px;
196   margin-top: 20px;
197   /* border: 1px solid cyan; */
198 }
199 
200 .selectContent>>>.el-collapse-item__content {
201   display: flex;
202   flex-direction: row;
203 }
204 
205 .selectContent .collapse>>>.el-collapse-item__content {
206   display: flex;
207   flex-direction: column;
208 }
209 
210 .selectContent .collapse>>>.el-collapse-item__content .inputClass {
211   display: flex;
212   flex-direction: row;
213 }
214 
215 .iconContentClass {
216   width: 100%;
217   height: 300px;
218   text-align: start;
219 }
220 
221 .iconContentClass span {
222   margin: 5px 0 0 27px;
223 }
224 
225 .selectContent .selectClass {
226   width: 40%;
227   height: 300px;
228   /* border-right: 1px solid cyan; */
229 }
230 
231 .selectContent .searchClass {
232   width: 60%;
233   height: 300px;
234   /* border: 1px solid cyan; */
235 }
236 
237 .selectContent .searchClass .contentClass {
238   width: 100%;
239   height: 100%;
240   background: #f9f6f65c;
241   border-left: 1px solid #ccc;
242 }
243 
244 .headerClass {
245   width: 50px;
246   height: 30px;
247   border: 1px solid red;
248 }
249 </style>
250   

 

解决vue3+element-plus 用不了icon的办法 https://blog.csdn.net/ddf__/article/details/127838247

标签:src,name,text,88,tag,切换,https,拖拽
From: https://www.cnblogs.com/shiyiersan/p/17182179.html

相关文章

  • flex控件拖拽效果
    <?xmlversion="1.0"encoding="utf-8"?><mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"layout="absolute"backgroundColor="#D99191"><mx:Arrayid="coffee......
  • JavaScript 前后切换图片
    <!DOCTYPEhtml><html> <head> <metacharset="UTF-8"> <title></title> <styletype="text/css"> *{ margin:0; padding:0; } #outer......
  • Flutter 下载篇 - 叁 | 网络库切换实践与思考
    前言本文是关于使用flutter_download_manager下载功能的实践和探索。我们将基于flutter_download_manager的功能扩展,改造成自己想要的样子。在阅读本文之前,建议先了解前两......
  • Win32 通过manifest切换Comctl32公共控件版本样式
    Comctl32公共控件有两个大版本v5和v6样式有一定区别,可以参考下述链接https://www.cnblogs.com/cyds/p/16251848.htmlvsc++现在默认有一个manifest内嵌在资源文件里,配置......
  • Flutter 下载篇 - 贰 | 当下载器遇上切换网络库
    需求背景继上篇《Flutter下载篇-壹|flutter_download_manager源码解析》中详细介绍了flutter_download_manager用法和原理。在优缺点中提到,该库纯Dart实现,支持......
  • 记录--手摸手带你撸一个拖拽效果
    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助前言最近看见一个拖拽效果的视频(抖音:艾恩小灰灰),看好多人评论说跟着敲也没效果,还有就是作者也不回复大......
  • Linux下 Jdk版本切换
    安装:甲骨文官网下jdk上传到云服务器解压:tar-zxvfjdk-7u79-linux-x64.tar.gz设置环境变量vim/etc/profile末尾加上exportJAVA_HOME=/usr/local/jdk1.8.0_351ex......
  • vue实现app页面切换效果
    pageAninmatevue-router实现webApp切换效果快速集成1.复制PageTransittion.vue到项目目录。2.修改router配置。Router.prototype.goBack=function(){this.isB......
  • Dockercompose conda 切换环境
    FROMcontinuumio/miniconda3:4.11.0#要创建的conda环境名ARGconda_env=XXXXX#将conda环境bin加入PATHENVPATH/opt/conda/bin:$PATH#一个RUN是一个shell环境,......
  • 系统切换故障记录
    故障一:POS端查询当天报表时,出现GiftVoucherIssued故障时间:2023年3月1日11:43故障店铺:WinnieLui 故障原因:  故障二: ......