首页 > 其他分享 >前端 vue 自定义导航栏组件高度及返回箭头 自定义 tabbar 图标

前端 vue 自定义导航栏组件高度及返回箭头 自定义 tabbar 图标

时间:2023-06-11 21:22:57浏览次数:85  
标签:index style vue tabbar 自定义 querySelector uni document

前端vue自定义导航栏组件高度及返回箭头 自定义tabbar图标, 下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=12986
效果图如下:

image
image

使用方法


// page.json 采用矢量图标设置返回箭头

    ,{

            "path" : "pages/Home/Home",

            "style" :                                                                                   

            {

                "navigationBarTitleText": "首页",

                "enablePullDownRefresh": false,

"app-plus": {

                    "titleNView": {



                        "buttons": [{



                            "float": "left",

                            "fontSize": "22px",

                            "fontSrc": "/static/iconfont.ttf", // 字体文件

                            "text": "" // 字体图标\u 开头,加上字体图标unicode后面四位

                        }

                        ]

                    }

            }



}

          }







// 自定义导航栏高度

agentUserAgent() {

var agent = navigator.userAgent;

if (/iphone|ipad|ipod/i.test(agent)) {

if (document.querySelector('.titleIos'))

document.querySelector('.titleIos').style.display = 'block';

document.querySelector('.uni-page-head').style.paddingTop = '44px';

document.querySelector('.uni-page-head').style.height = '88px';

}

},

HTML代码部分


<template>

<view>

<view class="content">

<!-- 适配iOS导航栏高度 -->

<view class="titleIos"></view>

首页

<button style="margin-top: 20px;" @click="goBackIndex">返回index页面</button>

</view>

</view>

</template>

JS代码 (引入组件 填充数据)


<script>

export default {

data() {

return {

}

},

onReady() {

// 自定义导航栏高度

this.agentUserAgent();

},

methods: {

// 自定义导航栏高度

agentUserAgent() {

var agent = navigator.userAgent;

if (/iphone|ipad|ipod/i.test(agent)) {

if (document.querySelector('.titleIos'))

document.querySelector('.titleIos').style.display = 'block';

document.querySelector('.uni-page-head').style.paddingTop = '44px';

document.querySelector('.uni-page-head').style.height = '88px';

}

},

// 返回菜单点击

onNavigationBarButtonTap(e) {

if (e.index == 0) {

uni.redirectTo({

url: '/pages/index/index'

})

}

},

goBackIndex() {

uni.redirectTo({

url: '/pages/index/index'

})

}

}

}

</script>

CSS


<style>

.content {

display: flex;

flex-direction: column;

align-items: center;

justify-content: center;

height: 100vh;

background: yellowgreen;

font-size: 26px;

}

</style>

标签:index,style,vue,tabbar,自定义,querySelector,uni,document
From: https://www.cnblogs.com/ccVue/p/17473622.html

相关文章

  • 掌握Vue生命周期,让你的前端开发效率翻倍!
    1Vue实例<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Vue实例</title><scriptsrc='../vue.js'></script></head><body><......
  • Vue3.js第一部分【核心篇】
    Vue3Vue核心Vue3快速上手​1.Vue3简介2020年9月18日,Vue.js发布3.0版本,代号:OnePiece(海贼王)耗时2年多、​2600+次提交、30+个RFC、600+次PR、99位贡献者github上的tags地址:​https://github.com/vuejs/vue-next/releases/tag/v3.0.0国内官网地址:​Vue.js-渐进式JavaScr......
  • [Vue warn]: Error compiling template: Component template should contain exactly
    报错信息:[Vuewarn]:Errorcompilingtemplate:Componenttemplateshouldcontainexactlyonerootelement.Ifyouareusingv-ifonmultipleelements,usev-else-iftochaintheminstead.2|3|4||......
  • 使用chatgpt根据openAI API key自定义关键词批量写文章
    使用chatgpt根据openAIAPIkey自定义关键词批量写文章使用方法:1.api.txt里放openaikey,每行一个,程序会随机使用一个KEY2.key.txt放关键词,根据关键词写文章。3.写好的文章会自动保存到wenzhang文件夹下。 写文章速度以来openaikey及本身网络速度。本视频录制采用1核1G机器运......
  • Vue_Django 登录注册+图书管理系统
    Vue前端注册页面点击查看代码<template><divclass="register"><el-row:gutter="20"><el-col:span="12":offset="6"><divclass="grid-contentbg-purple">&......
  • Spring Boot&Vue3前后端分离实战wiki知识库系统<八>--分类管理功能开发二
    接着上一次SpringBoot&Vue3前后端分离实战wiki知识库系统<七>--分类管理功能开发的分类功能继续完善。分类编辑功能优化:概述:现在分类编辑时的界面长这样:很明显目前的父分类的展现形式不太人性,这里需要指定父分类的id才可以,对于用户来说这种交互是反人道的,用户怎么知道父分类......
  • WFP必须掌握的技能之自定义控件——实战:自制上传文件显示进度按钮
    自定义控件在WPF开发中是很常见的,有时候某些控件需要契合业务或者美化统一样式,这时候就需要对控件做出一些改造。目录按钮设置圆角按钮上传文件相关定义测试代码话不多说直接看效果默认效果:上传效果:按钮设置圆角因为按钮本身没有CornerRadius属性,所以只能重写Butto......
  • vue报错Invalid VNode type: undefined
    报错项目启动后,部分内容没有显示出来。打开console后,显示[Vuewarn]:InvalidVNodetype:undefined(undefined)处理引入“defineAsyncComponent”实现异步引入。import{defineAsyncComponent}from'vue'。问题解决了。......
  • Vue插件:Vue-resource github搜索示例
     1:安装插件  vue-resourcevue的插件库,在vue1.0年代使用几率很高2:界面效果3:代码信息说明:该示例代码基本上是与《“Vue中通过事件总线方式组件间传递数据及调用Vue脚手架中的axios数据调用方式获取github提供的用户接口数据信息”》一文中的代码相同。        故:此处......
  • Vue 中通过事件总线方式组件间传递数据及调用 Vue脚手架中的axios数据调用方式获取git
    1:看界面效果2:代码结构3:代码内容3.1:引入第三方css样式表:bootstrap.css/*!*Bootstrapv3.3.5(http://getbootstrap.com)*Copyright2011-2015Twitter,Inc.*LicensedunderMIT(https://github.com/twbs/bootstrap/blob/master/LICENSE)*//*!normalize.cssv3.0.3|......