当前位置:首页 > 电脑知识 > 正文内容

这都可以?(使用vue.js)vue vue.js,Vue.js 实现的 3D Tab菜单,Vue.js 实现的 3D Tab菜单,

sauo3年前 (2022-12-15)电脑知识139

这是一款Vue.js实现的3D悬停Tab菜单,设计新颖创新,鼠标悬停展示3d卡片效果,三个Tab标签可切换,非常适合用于展示您的产品,作品等,喜欢不要犹豫。它的核心是基于vue和bootstrap实现,因此扩展起来非常方便,你可以任意添加或者减少tab页面数量,同时只要更新对应tab页面的CSS代码即可,无须修改js代码。

需要引入Vue.js库与bootstrap.js库

<scriptsrc=js/vue.min.js></script><scriptsrc=js/bootstrap.min.js></script>

HTML代码:

<divid="app-container"data-tilt><divid="app"><vue-tabsid="tabs"><v-tabtitle="First Tab"class="tab":selected="true"><divclass="tab-content"><divclass="tab-image first-image"></div><divclass="tab-content-text"><h1>First Header</h1><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt nu aliqua. Sollicit udin purus faucibus ornare aliquam ultrices sagittis orci a scelerisque a consectetur atna purus.</p></div></div></v-tab><v-tabtitle="Second Tab"class="tab"><divclass="tab-content"><divclass="tab-image second-image"></div><divclass="tab-content-text"><h1>Second Header</h1><p>Ac tortor vitae purus faucibus ornare suspendisse uis tristique sed nisi. Consectetur libero id ax faucibus in ornare faucibus nislt udin purus fi faucibus ac ornare aliquam ultrices in purus faucibu.</p></div></div></v-tab><v-tabtitle="Third Tab"class="tab"><divclass="tab-content"><divclass="tab-image third-image"></div><divclass="tab-content-text"><h1>Third Header</h1><p>Scelerisque fermentum dui faucibus in ornare id. Amet consectetur adipiscing elit duis tristique sollicitudin purus faucibus ornare aliquam ultrices sagittis nibh elit duis nubro tristique itae purus faucibus.</p></div></div></v-tab></vue-tabs></div></div>

核心代码插件:

(function(global, factory){typeof exports ===object&&typeofmodule!==undefined? factory(exports):typeof define ===function&& define.amd ? define([exports], factory):(factory((global.vueTabs ={})));}(this,(function(exports){use strict;var nestRE =/^(attrs|props|on|nativeOn|class|style|hook)$/;var babelHelperVueJsxMergeProps =function mergeJSXProps(objs){return objs.reduce(function(a, b){var aa, bb, key, nestedKey, temp;for(key in b){ aa = a[key]; bb = b[key];if(aa && nestRE.test(key)){// normalize classif(key ===class){if(typeof aa ===string){ temp = aa; a[key]= aa ={}; aa[temp]=true;}if(typeof bb ===string){ temp = bb; b[key]= bb ={}; bb[temp]=true;}}if(key ===on|| key ===nativeOn|| key ===hook){// merge functionsfor(nestedKey in bb){ aa[nestedKey]= mergeFn(aa[nestedKey], bb[nestedKey]);}}elseif(Array.isArray(aa)){ a[key]= aa.concat(bb);}elseif(Array.isArray(bb)){ a[key]=[aa].concat(bb);}else{for(nestedKey in bb){ aa[nestedKey]= bb[nestedKey];}}}else{ a[key]= b[key];}}return a;},{});};function mergeFn(a, b){returnfunction(){ a.apply(this, arguments); b.apply(this, arguments);};}varVueTabs={ name:vue-tabs, props:{ activeTabColor:String, activeTextColor:String, disabledColor:String, disabledTextColor:String,/** * Tab title position: center | bottom | top */ textPosition:{ type:String,default:center},/** * Tab type: tabs | pills */ type:{ type:String,default:tabs}, direction:{ type:String,default:horizontal},/** * Centers the tabs and makes the container div full width */ centered:Boolean, value:[String,Number,Object]}, data:function data(){return{ activeTabIndex:0, tabs:[]};}, computed:{ isTabShape:function isTabShape(){returnthis.type ===tabs;}, isStacked:function isStacked(){returnthis.direction ===vertical;}, classList:function classList(){var navType =this.isTabShape ?nav-tabs:nav-pills;var centerClass =this.centered ?nav-justified:;var isStacked =this.isStacked ?nav-stacked:;returnnav + navType ++ centerClass ++ isStacked;}, stackedClass:function stackedClass(){returnthis.isStacked ?stacked:;}, activeTabStyle:function activeTabStyle(){return{ backgroundColor:this.activeTabColor, color:this.activeTextColor };}}, methods:{ navigateToTab:function navigateToTab(index, route){this.changeTab(this.activeTabIndex, index, route);}, activateTab:function activateTab(index){this.activeTabIndex = index;var tab =this.tabs[index]; tab.active =true;this.$emit(input, tab.title);}, changeTab:function changeTab(oldIndex, newIndex, route){var oldTab =this.tabs[oldIndex]||{};var newTab =this.tabs[newIndex];if(newTab.disabled)return;this.activeTabIndex = newIndex; oldTab.active =false; newTab.active =true;this.$emit(input,this.tabs[newIndex].title);this.$emit(tab-change, newIndex, newTab, oldTab);this.tryChangeRoute(route);}, tryChangeRoute:function tryChangeRoute(route){if(this.$router && route){this.$router.push(route);}}, addTab:function addTab(item){var index =this.$slots.default.indexOf(item.$vnode);this.tabs.splice(index,0, item);}, removeTab:function removeTab(item){var tabs =this.tabs;var index = tabs.indexOf(item);if(index >-1){ tabs.splice(index,1);}}, getTabs:function getTabs(){if(this.$slots.default){returnthis.$slots.default.filter(function(comp){return comp.componentOptions;});}return[];}, findTabAndActivate:function findTabAndActivate(tabNameOrIndex){var indexToActivate =this.tabs.findIndex(function(tab, index){return tab.title === tabNameOrIndex || index === tabNameOrIndex;});if(indexToActivate ===this.activeTabIndex)return;if(indexToActivate !==-1){this.changeTab(this.activeTabIndex, indexToActivate);}else{this.changeTab(this.activeTabIndex,0);}}, renderTabTitle:function renderTabTitle(index){var position = arguments.length >1&& arguments[1]!==undefined? arguments[1]:top;var h =this.$createElement;if(this.tabs.length ===0)return;var tab =this.tabs[index];var active = tab.active, title = tab.title;var titleStyles ={ color:this.activeTabColor };if(position ===center) titleStyles.color =this.activeTextColor;var simpleTitle = h(span,{class:title title_+ position, style: active ? titleStyles :{}},[position ===center&&this.renderIcon(index), title]);if(tab.$slots.title)return tab.$slots.title;if(tab.$scopedSlots.title)return tab.$scopedSlots.title({ active: active, title: title, position: position, icon: tab.icon, data: tab.tabData });return simpleTitle;}, renderIcon:function renderIcon(index){var h =this.$createElement;if(this.tabs.length ===0)return;var tab =this.tabs[index];var icon = tab.icon;var simpleIcon = h(i,{class: icon },[\xA0]);if(!tab.$slots.title && icon)return simpleIcon;}, tabStyles:function tabStyles(tab){if(tab.disabled){return{ backgroundColor:this.disabledColor, color:this.disabledTextColor };}return{};}, renderTabs:function renderTabs(){var _this =this;var h =this.$createElement;returnthis.tabs.map(function(tab, index){if(!tab)return;var route = tab.route, id = tab.id, title = tab.title, icon = tab.icon, tabId = tab.tabId;var active = _this.activeTabIndex === index;return h(li, babelHelperVueJsxMergeProps([{ attrs:{ name:tab, id:t-+ tabId,aria-selected: active,aria-controls:p-+ tabId, role:tab},class:[tab,{ active: active },{ disabled: tab.disabled }], key: title },{ on:{click:function click($event){for(var _len = arguments.length, attrs =Array(_len >1? _len -1:0), _key =1; _key < _len; _key++){ attrs[_key -1]= arguments[_key];}(function(){return!tab.disabled && _this.navigateToTab(index, route);}).apply(undefined,[$event].concat(attrs));}}}]),[_this.textPosition ===top&& _this.renderTabTitle(index, _this.textPosition), h(a, babelHelperVueJsxMergeProps([{ attrs:{ href:#, role:tab}, style: active ? _this.activeTabStyle : _this.tabStyles(tab),class:[{active_tab: active },tabs__link]},{ on:{click:function click($event){for(var _len2 = arguments.length, attrs =Array(_len2 >1? _len2 -1:0), _key2 =1; _key2 < _len2; _key2++){ attrs[_key2 -1]= arguments[_key2];}(function(e){ e.preventDefault();returnfalse;}).apply(undefined,[$event].concat(attrs));}}}]),[_this.textPosition !==center&&!tab.$slots.title && _this.renderIcon(index), _this.textPosition ===center&& _this.renderTabTitle(index, _this.textPosition)]), _this.textPosition ===bottom&& _this.renderTabTitle(index, _this.textPosition)]);});}}, render:function render(){var h = arguments[0];var tabList =this.renderTabs();return h(div,{class:[vue-tabs,this.stackedClass]},[h(div,{class:[{nav-tabs-navigation:!this.isStacked },{left-vertical-tabs:this.isStacked }]},[h(div,{class:[nav-tabs-wrapper,this.stackedClass]},[h(ul,{class:this.classList, attrs:{ role:tablist}},[tabList])])]), h(div,{class:[tab-content,{right-text-tabs:this.isStacked }]},[this.$slots.default])]);}, watch:{ tabs:function tabs(newList){if(newList.length >0&&!this.value){if(newList.length <=this.activeTabIndex){this.activateTab(this.activeTabIndex -1);}else{this.activateTab(this.activeTabIndex);}}if(newList.length >0&&this.value){this.findTabAndActivate(this.value);}}, value:function value(newVal){this.findTabAndActivate(newVal);}}};varVTab={ name:v-tab, props:{ title:{ type:String,default:}, icon:{ type:String,default:}, tabData:{default:null},/*** * Function to execute before tab switch. Return value must be boolean * If the return result is false, tab switch is restricted */ beforeChange:{ type:Function}, id:String, route:{ type:[String,Object]}, disabled:Boolean, transitionName:String, transitionMode:String}, computed:{ isValidParent:function isValidParent(){returnthis.$parent.$options.name ===vue-tabs;}, hash:function hash(){return#+this.id;}, tabId:function tabId(){returnthis.id ?this.id :this.title;}}, data:function data(){return{ active:false, validationError:null};}, mounted:function mounted(){this.$parent.addTab(this);}, destroyed:function destroyed(){if(this.$el &&this.$el.parentNode){this.$el.parentNode.removeChild(this.$el);}this.$parent.removeTab(this);}, render:function render(){var h = arguments[0];return h(section,{class:tab-container, attrs:{ id:p-+this.tabId,aria-labelledby:t-+this.tabId, role:tabpanel}, directives:[{ name:show, value:this.active }]},[this.$slots.default]);}};varVueTabsPlugin={ install:function install(Vue){Vue.component(vue-tabs,VueTabs);Vue.component(v-tab,VTab);}};// Automatic installation if Vue has been added to the global scope.if(typeof window !==undefined&& window.Vue){ window.Vue.use(VueTabsPlugin); window.VueTabs=VueTabsPlugin;} exports[default]=VueTabsPlugin; exports.VueTabs=VueTabs; exports.VTab=VTab;Object.defineProperty(exports,__esModule,{ value:true});})));

我们可以在页面上调用插件的初始化代码,即可完成这个vue tab插件。

newVue({ el:"#app",}); $(.js-tilt).tilt({})
(window.slotbydup = window.slotbydup || []).push({ id: "u6835052", container: "_96bek913mdb", async: true });

本文链接:http://blog.sauo.top/?id=519 感谢分享!

分享到:

扫描二维码推送至手机访问。

版权声明:本文由冬眠先生个人博客发布,如需转载请注明出处。

本文链接:http://blog.sauo.top/?id=519

分享给朋友:

“这都可以?(使用vue.js)vue vue.js,Vue.js 实现的 3D Tab菜单,Vue.js 实现的 3D Tab菜单,” 的相关文章

万万没想到(Ubuntu安装ssh服务)ubuntu配置ssh服务器,ubuntu安装ssh服务器的方法,ubuntu安装ssh服务器的方法,

万万没想到(Ubuntu安装ssh服务)ubuntu配置ssh服务器,ubuntu安装ssh服务器的方法,ubuntu安装ssh服务器的方法,

免费领取腾讯云服务器! 安装了一个ubuntu系统,想着在内网中用ssh进行远程连接管理。下面这篇博文就说说如果在ubuntu系统中安装ssh远程管理服务。 ubuntu 安装ssh服务器的方法 1、安装 openssh-s...

这都可以?(php获取服务器信息)php获取客户端,php获取服务器操作系统类型的方法,php获取服务器操作系统类型的方法,

免费领取腾讯云服务器! 利用php脚本中的 php_uname() 函数与 PHP_OS 变量可以获取服务器操作系统的类型,具体的使用方法如下。 php获取服务器操作系统的方法 1、php_uname() 获取服务器操作系统...

没想到(imagettftext函数)imagettftext函数支持的编码类型,imagettftext(): any2eucjp(): invalid code in input string 错误解决方法,imagettftext(): any2eucjp(): invalid code in input string 错误解决方法,

免费领取腾讯云服务器! 最近在研究关于php生成图片的东西,发现了 imagettftext() 函数中一个不是错误的错误,具体的错误情况如下所示。 错误代码:...

硬核推荐(windows查看文件的md5值)windows 查看md5值,window 系统查看文件md5值的方法,window 系统查看文件md5值的方法,

硬核推荐(windows查看文件的md5值)windows 查看md5值,window 系统查看文件md5值的方法,window 系统查看文件md5值的方法,

免费领取腾讯云服务器! 在winodw系统上查看一个文件的md5值,不用去安装专门查看文件md5的软件,只需要使用 cmd 命令即可。 window 查看 md5 值的方法 1、打开CMD命令窗口 (1)、快...

墙裂推荐(js判断ip是否合法)判断ipv4地址是否合法,js代码判断IP地址的合法性(只支持IPV4),js代码判断IP地址的合法性(只支持IPV4),

免费领取腾讯云服务器! 客户定制了一个IPV4格式的IP地址在线查询的工具,需要用户在前台输入IPV4格的IP地址,为了防止用户输入的IPV4格式的IP错误,又减少后端的服务器资源的浪费,就想到了先在前台用JS脚本判断一下,用户输入的IPV4地址是否合法。...

没想到(php获取IP地址)php获取当前时间的函数,php获取顶级域名/一级域名的方法,php获取顶级域名/一级域名的方法,

免费领取腾讯云服务器! 列出几个网上收集的关于利用php脚本获取顶级域名的方法,可能分析的不是很完全,大家可以参考一下,适当的做一些调整。 php获取顶级域名的方法 示例1: Jav...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。