亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

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

<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: {
?? ??? ?//設置名字
?? ??? ?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>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • vue?eslint報錯error?"Component?name?"*****"?should?always?be?multi-word"解決

    vue?eslint報錯error?"Component?name?"*****"

    這篇文章主要給大家介紹了關于vue?eslint報錯error?“Component?name?“*****“?should?always?be?multi-word”的解決方法,文中通過圖文以及實例代碼介紹的非常詳細,需要的朋友可以參考下
    2022-09-09
  • vue-cli3.0 axios跨域請求代理配置方式及端口修改

    vue-cli3.0 axios跨域請求代理配置方式及端口修改

    這篇文章主要介紹了vue-cli3.0 axios跨域請求代理配置方式及端口修改,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-10-10
  • element-plus+Vue3實現(xiàn)表格數(shù)據(jù)動態(tài)渲染

    element-plus+Vue3實現(xiàn)表格數(shù)據(jù)動態(tài)渲染

    在Vue中,el-table是element-ui提供的強大表格組件,可以用于展示靜態(tài)和動態(tài)表格數(shù)據(jù),本文主要介紹了element-plus+Vue3實現(xiàn)表格數(shù)據(jù)動態(tài)渲染,感興趣的可以了解一下
    2024-03-03
  • Element PageHeader頁頭的使用方法

    Element PageHeader頁頭的使用方法

    這篇文章主要介紹了Element PageHeader頁頭的使用方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-07-07
  • vue2?利用echarts?單獨繪制省份的步驟

    vue2?利用echarts?單獨繪制省份的步驟

    這篇文章主要介紹了vue2?利用echarts?單獨繪制省份,首先引入所需要的第三方模塊,通過示例代碼給大家介紹的非常詳細,文章末尾給大家補充介紹了vue2.x結合echarts2實現(xiàn)顯示具體省份熱力圖的問題,需要的朋友可以參考下
    2022-01-01
  • 編寫v-for循環(huán)的技巧匯總

    編寫v-for循環(huán)的技巧匯總

    這篇文章主要介紹了編寫更好的v-for循環(huán)的6種技巧,幫助大家更好的理解和使用vue框架,感興趣的朋友可以了解下
    2020-12-12
  • Vue中map()的用法案例

    Vue中map()的用法案例

    map()函數(shù)定義在JS的array中,它返回一個新的數(shù)組,下面這篇文章主要給大家介紹了關于Vue中map()的用法案例,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下
    2022-07-07
  • Vue封裝一個簡單輕量的上傳文件組件的示例

    Vue封裝一個簡單輕量的上傳文件組件的示例

    這篇文章主要介紹了Vue封裝一個簡單輕量的上傳文件組件的示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • 詳解如何使用 vue-cli 開發(fā)多頁應用

    詳解如何使用 vue-cli 開發(fā)多頁應用

    本篇文章主要介紹了詳解如何使用 vue-cli 開發(fā)多頁應用,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-12-12
  • 解決vue打包css文件中背景圖片的路徑問題

    解決vue打包css文件中背景圖片的路徑問題

    今天小編就為大家分享一篇解決vue打包css文件中背景圖片的路徑問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09

最新評論