html 底部导航栏中间凸起效果源码,Nuxt/Vue仿咸鱼Tabbar凸起效果|vue自定义导航栏...

引言在手机端项目开发时,很多场景下标签栏TabBar和导航栏NavBar功能必不可少。由于Nuxt项目中需要用到类似咸鱼底部凸起导航效果,只能自己动手造一个自定义导航组件。

de0e421375c626afbea96183973eaf68.png

如上图:在项目中实例效果

ok,下面就详细讲解下实现方法。

首先,需要在components目录下新建 headerBar.vue 和 tabBar.vue 页面。

1495db7af61835df7ddb0d3e8aabec64.png

紧接着,在 plugins 目录下新建 componentsInstall.js 文件并引入即可。

cf284539be0ababe04b9996f9c1d4ca8.png

Nuxt自定义导航条headerBar

/**

* @Desc Vue自定义导航条headerBar

* @Time andy by 2020-10-06

* @About Q:282310962 wx:xy190310

*/

export default {

props: {

// 是否返回

back: { type: [Boolean, String], default: true },

// 标题

title: { type: String, default: '' },

// 标题颜色

color: { type: String, default: '#fff' },

// 背景颜色

bgcolor: { type: String, default: '#22d59c' },

// 标题是否居中

center: { type: [Boolean, String], default: false },

// 搜索框

search: { type: [Boolean, String], default: false },

// 是否固定

fixed: { type: [Boolean, String], default: false },

// 背景透明

transparent: { type: [Boolean, String], default: false },

// 设置层级

zIndex: { type: [Number, String], default: '2021' },

},

data() {

return {}

},

methods: {},

}

874d17b263e7dc2ca4d7ea2d9d8a0dd9.png

29fc9daf9d9a28fde66b1af3c1dde4a6.png

ad65f8c06c9b0811f9eeff199eff7acd.png

logo.pngNuxt

保存

06a5d6900cde9456dd32c5700367e65f.png

2bd073a0f04bf081f781521a07fbff41.png

a903e28148a859acae4414dad18fe3bc.png

Nuxt自定义Tabbar组件

ea1d25caaa0374d9d3c68317d235ee35.png

export default {

props: {

current: { type: [Number, String], default: 0 },

// 背景颜色

bgcolor: { type: String, default: '#fff' },

// 颜色

color: { type: String, default: '#999' },

// 点击后颜色

activeColor: { type: String, default: '#22d59c' },

// 是否固定

fixed: { type: [Boolean, String], default: false },

// tab选项

tabs: {

type: Array,

default: () => null

}

},

data() {

return {

currentTabIndex: this.current

}

},

created() {

const _pagePath = this.$route.path

this.tabs.map((val, index) => {

if(val.pagePath == _pagePath) {

this.currentTabIndex = index

}

})

},

methods: {

switchTabs(index, item) {

this.currentTabIndex = index

this.$emit('click', index)

if(item.pagePath) {

this.$router.push(item.pagePath)

}

}

},

}

fd2461ce11676577858eeb6c9c91a5c4.png

2b1113b1e0c0666beb84e77d170376ed.png

/>// tabbar点击事件

handleTabbar(index) {

this.$toast('tabbar索引值:' + index);

},

另外还支持咸鱼凸起效果,只需配置 dock: true 属性即可。根据项目需要支持自定义多个tab选项。

0b7a83ee0e0dc68b005f81b6fec7f437.png

94ac55e52042e75b5afc75660503e5d8.png

/>

okey,基于Nuxt自定义仿咸鱼导航组件就分享到这里。希望对大家有所帮助!!✍✍

最后附上一个基于Nuxt/Vue自定义弹框组件

https://segmentfault.com/a/1190000027085208

b739ec46bb5c46d9c0aa4ce35ba1ea56.png

关于找一找教程网

本站文章仅代表作者观点,不代表本站立场,所有文章非营利性免费分享。

本站提供了软件编程、网站开发技术、服务器运维、人工智能等等IT技术文章,希望广大程序员努力学习,让我们用科技改变世界。

[Nuxt/Vue仿咸鱼Tabbar凸起效果|vue自定义导航栏]http://www.zyiz.net/tech/detail-147877.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值