直播app原始碼,預設顯示搜尋框 保留搜尋條件
直播app原始碼,預設顯示搜尋框 保留搜尋條件
<template> <div :class="{'show':show}"> <svg-icon class-name="search-icon" icon-class="search" @click.stop="click" /> <el-select ref="headerSearchSelect" v-model="search" :remote-method="querySearch" filterable default-first-option remote placeholder="選單快捷搜尋" @change="change" > <el-option v-for="option in options" :key="option.item.path" :value="option.item" :label="option.item.title.join(' > ')" /> </el-select> </div> </template> <script> // fuse is a lightweight fuzzy-search module // make search results more in line with expectations import Fuse from 'fuse.js/dist/fuse.min.js' import path from 'path' export default { name: 'HeaderSearch', data() { return { search: '', options: [], searchPool: [], show: true,//右上角搜尋框 預設開啟 fuse: undefined } }, computed: { routes() { return this.$store.getters.permission_routes } }, watch: { routes() { this.searchPool = this.generateRoutes(this.routes) }, searchPool(list) { this.initFuse(list) }, show(value) { if (value) { document.body.addEventListener('click', this.close) } else { document.body.removeEventListener('click', this.close) } } }, mounted() { this.searchPool = this.generateRoutes(this.routes) }, methods: { click() { this.show = !this.show if (this.show) { this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.focus() } }, close() { this.$refs.headerSearchSelect && this.$refs.headerSearchSelect.blur() // this.options = [] //清空搜尋結果;註釋掉:保留上一次的搜尋結果 //this.show = false //false 關閉搜尋框;註釋掉:搜尋框停留 }, change(val) { const path = val.path; if(this.ishttp(val.path)) { // http(s):// 路徑新視窗開啟 const pindex = path.indexOf("http"); window.open(path.substr(pindex, path.length), "_blank"); } else { this.$router.push(val.path) } //this.search = '' //清空搜尋詞;註釋掉:保留上一次的搜尋詞 //this.options = [] //清空搜尋結果;註釋掉:保留上一次的搜尋結果 this.$nextTick(() => { //this.show = false //false 關閉搜尋框;註釋掉:搜尋框停留 }) }, initFuse(list) { this.fuse = new Fuse(list, { shouldSort: true, threshold: 0.4, location: 0, distance: 100, minMatchCharLength: 1, keys: [{ name: 'title', weight: 0.7 }, { name: 'path', weight: 0.3 }] }) }, // Filter out the routes that can be displayed in the sidebar // And generate the internationalized title generateRoutes(routes, basePath = '/', prefixTitle = []) { let res = [] for (const router of routes) { // skip hidden router if (router.hidden) { continue } const data = { path: !this.ishttp(router.path) ? path.resolve(basePath, router.path) : router.path, title: [...prefixTitle] } if (router.meta && router.meta.title) { data.title = [...data.title, router.meta.title] if (router.redirect !== 'noRedirect') { // only push the routes with title // special case: need to exclude parent router without redirect res.push(data) } } // recursive child routes if (router.children) { const tempRoutes = this.generateRoutes(router.children, data.path, data.title) if (tempRoutes.length >= 1) { res = [...res, ...tempRoutes] } } } return res }, querySearch(query) { if (query !== '') { this.options = this.fuse.search(query) } else { this.options = [] } }, ishttp(url) { return url.indexOf(') !== -1 || url.indexOf(') !== -1 } } } </script> <style scoped> .header-search { font-size: 0 !important; .search-icon { cursor: pointer; font-size: 18px; vertical-align: middle; } .header-search-select { font-size: 18px; transition: width 0.2s; width: 0; overflow: hidden; background: transparent; border-radius: 0; display: inline-block; vertical-align: middle; ::v-deep .el-input__inner { border-radius: 0; border: 0; padding-left: 0; padding-right: 0; box-shadow: none !important; border-bottom: 1px solid #d9d9d9; vertical-align: middle; } } &.show { .header-search-select { width: 210px; margin-left: 10px; } } } </style>
以上就是直播app原始碼,預設顯示搜尋框 保留搜尋條件, 更多內容歡迎關注之後的文章
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2996580/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 直播開發app,實時搜尋、搜尋引擎框APP
- github條件搜尋Github
- 直播軟體開發,自定義搜尋欄的圖示樣式和搜尋框
- 線上直播系統原始碼,實現搜尋後介面顯示商品列表效果原始碼
- TextView搜尋文字高亮顯示TextView
- 直播軟體app開發,刪除主頁搜尋框APP
- 視訊直播app原始碼,軟體主頁向下滑動時隱藏搜尋框APP原始碼
- 直播系統程式碼,常用搜尋中搜尋歷史,搜尋推薦功能
- 搜尋框帶有搜尋提示點選消失程式碼例項
- js之搜尋框JS
- 搜尋框佈局
- WIN10開始搜尋框亂碼怎麼辦 WIN10電腦開始搜尋框顯示亂碼修復方法Win10
- windows10系統下搜尋框黑屏失靈不顯示任何搜尋結果如何解決Windows
- JavaScript搜尋框提示文字JavaScript
- jQuery 伸縮搜尋框jQuery
- laravel Es搜尋 檢索高亮顯示Laravel
- 利用Lucene搜尋Java原始碼Java原始碼
- android studio 搜尋只顯示100條資料Android
- Win10系統搜尋欄搜尋不顯示結果如何解決Win10
- 直播平臺開發,基礎搜尋方式之拼音搜尋
- Windows10系統禁用小娜保留搜尋框的方法Windows
- 搭建直播平臺,給首頁配備搜尋框
- Jquery + Bootstrap 實現搜尋框jQueryboot
- jQuery DataTables新增自定義多個搜尋條件jQuery
- 【Django】組合條件的搜尋功能實現Django
- 易優searchform功能:文件標題搜尋,預設搜尋整站-EyouCms手冊ORM
- div css搜尋框效果程式碼例項CSS
- 美觀的搜尋框程式碼例項
- Windows10搜尋框怎麼關閉_Win10如何關閉搜尋框WindowsWin10
- 解決jive搜尋結果中的中文搜尋字串高亮度顯示的方法字串
- 海量資料搜尋---搜尋引擎
- 雲搜尋服務在APP搜尋場景的應用APP
- 51_初識搜尋引擎_上機動手實戰多搜尋條件組合查詢
- 成品直播原始碼,實現在平臺內部的搜尋原始碼
- 線上直播系統原始碼,vue實現搜尋文字高亮功能原始碼Vue
- 前端實時搜尋框模擬前端
- JavaScript仿新浪微博搜尋框功能JavaScript
- 搜尋框或者UITextField使用ReactiveCocoaUIReact