最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue可左右滑動按鈕組組件使用詳解

 更新時間:2022年02月27日 13:00:56   作者:覓長生  
這篇文章主要為大家詳細介紹了基于Vue可左右滑動按鈕組組件,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了基于Vue可左右滑動按鈕組組件,供大家參考,具體內(nèi)容如下

左右兩箭頭控制按鈕組左右移動,雙擊到最左或最右邊,功能比較簡單。如下所示

<template>
?? ?<div class="demoButtons">
?? ??? ?<div class="buttonF">
?? ??? ??? ?<el-row style="height:30px ">
?? ??? ??? ??? ?<el-col class="lableI"><i class="el-icon-arrow-left " @click="moveButtons('left')" @dblclick="moveSide('left')" /></el-col>
?? ??? ??? ??? ?<el-col ref="buttonBody" class="buttonBody">
?? ??? ??? ??? ??? ?<el-row id="buttonRow" ref="buttonRow">
?? ??? ??? ??? ??? ??? ?<el-tag :style="{'width':buttonWidth+'px'}" v-for="(item, index) in buttonData" :key="index" :type="index == clickIndex ? '' : 'info'" @click="resetData(index, item)">
?? ??? ??? ??? ??? ??? ??? ?<el-tooltip v-if="item.name && item.name.length > ?parseInt(buttonWidth/12) - 1" placement="top" :content="item.name" effect="light">
?? ??? ??? ??? ??? ??? ??? ??? ?<span>{{ ?resetName(item.name) }}</span>
?? ??? ??? ??? ??? ??? ??? ?</el-tooltip>
?? ??? ??? ??? ??? ??? ??? ?<span v-else>{{ item.name }}</span>
?? ??? ??? ??? ??? ??? ?</el-tag>
?? ??? ??? ??? ??? ?</el-row>
?? ??? ??? ??? ?</el-col>
?? ??? ??? ??? ?<el-col class="lableI"><i class="el-icon-arrow-right " @click="moveButtons('right')" @dblclick="moveSide('right')" /></el-col>
?? ??? ??? ?</el-row>
?? ??? ?</div>
?? ?</div>
</template>
<script>
import $ from 'jquery'
export default {
?? ?props: {
?? ??? ?buttonData: {
?? ??? ??? ?type: Array,
?? ??? ??? ?default: () => {
?? ??? ??? ??? ?return []
?? ??? ??? ?}
?? ??? ?},
?? ??? ?buttonWidth: {
?? ??? ??? ?type: Number,
?? ??? ??? ?default: 62
?? ??? ?}
?? ?},
?? ?data () {
?? ??? ?return {
?? ??? ??? ?clickIndex: 0,
?? ??? ??? ?currentSite: 0,
?? ??? ??? ?showCount: 0,
?? ??? ??? ?clickTimer: null,
?? ??? ?}
?? ?},
?? ?watch: {},
?? ?created () {
?? ??? ?// this.setButtons()
?? ?},
?? ?mounted () {
?? ??? ?this.$nextTick(() => {
?? ??? ??? ?this.showCount = parseInt(this.$refs.buttonBody.$el.clientWidth / this.buttonWidth) // 一行能展示幾個按鈕
?? ??? ?})
?? ?},

?? ?methods: {
?? ??? ?//設(shè)置名字
?? ??? ?resetName (val) {
?? ??? ??? ?let i = parseInt(this.buttonWidth / 12) - 1;
?? ??? ??? ?if (val && val.length > i) {
?? ??? ??? ??? ?return val.slice(0, i)
?? ??? ??? ?} else {
?? ??? ??? ??? ?return val
?? ??? ??? ?}
?? ??? ?},
?? ??? ?// 單擊移一格
?? ??? ?moveButtons (val) {
?? ??? ??? ?if (this.clickTimer) {
?? ??? ??? ??? ?window.clearTimeout(this.clickTimer)
?? ??? ??? ??? ?this.clickTimer = null
?? ??? ??? ?}
?? ??? ??? ?this.clickTimer = window.setTimeout(() => {
?? ??? ??? ??? ?this.$nextTick(() => {
?? ??? ??? ??? ??? ?if (val == 'left') {
?? ??? ??? ??? ??? ??? ?if (this.currentSite < 0) {
?? ??? ??? ??? ??? ??? ??? ?this.currentSite = this.currentSite + this.buttonWidth
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?} else {
?? ??? ??? ??? ??? ??? ?const totalCount = this.buttonData.length // 總共幾個按鈕
?? ??? ??? ??? ??? ??? ?const showIndex = -parseInt(this.currentSite / this.buttonWidth) // 向左移了幾個按鈕
?? ??? ??? ??? ??? ??? ?console.log(totalCount, 'totalLength', this.showCount, showIndex)
?? ??? ??? ??? ??? ??? ?if (showIndex + this.showCount < totalCount) {
?? ??? ??? ??? ??? ??? ??? ?this.currentSite = this.currentSite - this.buttonWidth
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?$('#buttonRow').animate({ marginLeft: this.currentSite + 'px' })
?? ??? ??? ??? ?})
?? ??? ??? ?}, 300)
?? ??? ?},
?? ??? ?// 雙擊到邊
?? ??? ?moveSide (val) {
?? ??? ??? ?if (this.clickTimer) {
?? ??? ??? ??? ?window.clearTimeout(this.clickTimer)
?? ??? ??? ??? ?this.clickTimer = null
?? ??? ??? ?}
?? ??? ??? ?this.$nextTick(() => {
?? ??? ??? ??? ?if (val == 'left') {
?? ??? ??? ??? ??? ?this.currentSite = 0
?? ??? ??? ??? ?} else {
?? ??? ??? ??? ??? ?const totalCount = this.buttonData.length // 總共幾個按鈕
?? ??? ??? ??? ??? ?if (totalCount > this.showCount) {
?? ??? ??? ??? ??? ??? ?this.currentSite = -((totalCount - this.showCount) * this.buttonWidth)
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?}
?? ??? ??? ??? ?$('#buttonRow').animate({ marginLeft: this.currentSite + 'px' })
?? ??? ??? ?})
?? ??? ?},

?? ??? ?setButtons (data) {
?? ??? ??? ?this.buttonData = data
?? ??? ?},
?? ??? ?resetData (index, data) {
?? ??? ??? ?this.clickIndex = index
?? ??? ??? ?this.$emit('resetData', data)
?? ??? ?}
?? ?}
}
</script>
<style lang="scss" scoped>
.demoButtons {
?? ?width: 100%;
?? ?height: 100%;
}
.buttonF {
?? ?width: 100%;
?? ?margin: 0 auto;
?? ?height: 30px;
?? ?line-height: 30px;
}
.lableI {
?? ?height: 30px;
?? ?line-height: 30px;
?? ?width: 20px;
?? ?cursor: pointer;
}
.buttonBody {
?? ?overflow: hidden;
?? ?height: 30px;
?? ?line-height: 30px;
?? ?width: calc(100% - 40px);
?? ?white-space: nowrap;
}

.el-tag {
?? ?text-align: center;
?? ?padding: 0px 8px !important;
?? ?height: 28px;
?? ?line-height: 28px;
?? ?cursor: pointer;
?? ?border-radius: 0px !important;
?? ?overflow: hidden;
?? ?font-size: 12px;
}
</style>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • React和Vue實現(xiàn)路由懶加載的示例代碼

    React和Vue實現(xiàn)路由懶加載的示例代碼

    路由懶加載是一項關(guān)鍵技術(shù),它可以幫助我們提高Web應(yīng)用的加載速度,本文主要介紹了React和Vue實現(xiàn)路由懶加載的示例代碼,具有一定的參考價值,感興趣的可以了解一下
    2024-01-01
  • Vue編程三部曲之模型樹優(yōu)化示例

    Vue編程三部曲之模型樹優(yōu)化示例

    這篇文章主要為大家介紹了Vue編程三部曲之模型樹優(yōu)化示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-07-07
  • vue3輸入單號和張數(shù)如何自動生成連號的單號

    vue3輸入單號和張數(shù)如何自動生成連號的單號

    最近遇到這樣的需求輸入連號事件,需要在表格中輸入物流單號,物流號碼,生成的數(shù)量,名稱,點擊確定自動生成固定數(shù)量的連號物流單號,本文重點介紹vue3輸入單號和張數(shù),自動生成連號的單號,感興趣的朋友一起看看吧
    2024-02-02
  • vue-cli 3.x配置跨域代理的實現(xiàn)方法

    vue-cli 3.x配置跨域代理的實現(xiàn)方法

    這篇文章主要介紹了vue-cli 3.x配置跨域代理的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Vue.js獲取手機系統(tǒng)型號、版本、瀏覽器類型的示例代碼

    Vue.js獲取手機系統(tǒng)型號、版本、瀏覽器類型的示例代碼

    這篇文章主要介紹了vue js獲取手機系統(tǒng)型號、版本、瀏覽器類型的示例代碼,代碼簡單易懂,非常不錯具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-05-05
  • vue單個元素綁定多個事件問題(例如點擊綁定多個事件方法)

    vue單個元素綁定多個事件問題(例如點擊綁定多個事件方法)

    這篇文章主要介紹了vue單個元素綁定多個事件問題(例如點擊綁定多個事件方法),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • 使用vue-json-viewer實現(xiàn)JSON數(shù)據(jù)可視化詳解

    使用vue-json-viewer實現(xiàn)JSON數(shù)據(jù)可視化詳解

    vue-json-viewer?是一個用于在?vue.js?應(yīng)用中展示?JSON?數(shù)據(jù)的插件,它提供了一種直觀和美觀的方式來可視化?JSON?數(shù)據(jù),下面我們來看看如何使用它進行JSON數(shù)據(jù)可視化吧
    2025-01-01
  • 基于vue實現(xiàn)多引擎搜索及關(guān)鍵字提示

    基于vue實現(xiàn)多引擎搜索及關(guān)鍵字提示

    這篇文章主要為大家詳細介紹了基于vue實現(xiàn)多引擎搜索及關(guān)鍵字提示的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • vue中實現(xiàn)代碼高亮與語法著色的方法介紹

    vue中實現(xiàn)代碼高亮與語法著色的方法介紹

    在Vue的開發(fā)過程中,我們經(jīng)常需要展示代碼片段或者進行代碼高亮與語法著色,Vue提供了多種方式來實現(xiàn)代碼高亮與語法著色,本文將為你詳細介紹這些方法,需要的朋友可以參考下
    2023-06-06
  • vue-router跳轉(zhuǎn)方式的區(qū)別解析

    vue-router跳轉(zhuǎn)方式的區(qū)別解析

    在Vue中,router-link稱為聲明式路由,:to綁定為跳轉(zhuǎn)的目標地址,一種是通過name,另一種是path,這篇文章主要介紹了vue-router跳轉(zhuǎn)方式的區(qū)別,需要的朋友可以參考下
    2022-12-12

最新評論

萝北县| 乐山市| 西平县| 凤山市| 泰和县| 什邡市| 棋牌| 朝阳县| 定安县| 洪泽县| 图们市| 台江县| 阆中市| 中江县| 清丰县| 梅州市| 雅江县| 开封县| 康定县| 湟中县| 武平县| 望城县| 房产| 江达县| 伊春市| 襄汾县| 桃江县| 于都县| 江永县| 道孚县| 盘锦市| 张掖市| 吉首市| 清水县| 文登市| 青海省| 沙雅县| 当阳市| 平昌县| 乌鲁木齐县| 广河县|