当前位置: 首页 > news >正文

深圳网站制作长沙移动建站优化

深圳网站制作长沙,移动建站优化,茌平网站开发,外国网站备案目录 uni.setNavigationBarTitle动态设置标题 uni.showNavigationBarLoading为标题添加加载动画与uni.hideNavigationBarLoading停止加载动画 ​编辑 uni.setNavigationBarColor用于设置导航栏的颜色,包括背景颜色和文字颜色。这对于自定义应用的主题和风格非常有…

目录

 uni.setNavigationBarTitle动态设置标题

uni.showNavigationBarLoading为标题添加加载动画与uni.hideNavigationBarLoading停止加载动画

​编辑

  uni.setNavigationBarColor用于设置导航栏的颜色,包括背景颜色和文字颜色。这对于自定义应用的主题和风格非常有用。

uni.setTabBarItem设置 tabBar 项的文本

uni.setTabBarStyle(OBJECT)

uni.hideTabBar(OBJECT)

uni.showTabBar(OBJECT)

uni.setTabBarBadge(OBJECT)

uni.removeTabBarBadge(OBJECT)

uni.showTabBarRedDot(OBJECT)

uni.hideTabBarRedDot(OBJECT)


 uni.setNavigationBarTitle动态设置标题

 是一个用于设置页面导航栏标题的方法。它允许你在页面加载后动态地更改导航栏的标题。

uni.setNavigationBarTitle(OBJECT)

代码示例

<template><view class="content"><!-- 设置导航栏标题按钮 --><button @click="changeNavigationBarTitle">更改导航栏标题</button></view>
</template><script setup>// 更改导航栏标题const changeNavigationBarTitle = () => {uni.setNavigationBarTitle({title: '新标题', // 新的导航栏标题success: function() {console.log('导航栏标题设置成功');},fail: function(err) {console.error('设置导航栏标题失败:', err);}});};
</script>

详细解释

  1. title:必须,字符串类型,表示新的导航栏标题。
  2. success:可选,成功回调函数,当设置成功时触发。
  3. fail:可选,失败回调函数,当设置失败时触发。

uni.showNavigationBarLoading为标题添加加载动画与uni.hideNavigationBarLoading停止加载动画


<template><!-- 页面的主要内容区域 --><view class="content"><!-- 点击按钮时触发 showLoading 方法 --><button @click="showLoading">加载</button></view>
</template><script setup>// 显示加载指示器const showLoading = () => {// 显示导航栏中的加载指示器uni.showNavigationBarLoading();// 模拟异步操作,2秒后隐藏加载指示器setTimeout(() => {// 隐藏导航栏中的加载指示器uni.hideNavigationBarLoading();}, 2000);};
</script><style>/* 页面内容区域的样式 */.content {padding: 20px; /* 内边距为 20px */}
</style>




所用的 API 解释

  1.  uni.showNavigationBarLoading

    • 功能:在导航栏中显示一个加载指示器。
    • 用途:当页面需要加载数据或执行耗时操作时,显示一个加载指示器,以提升用户体验。
    • 参数:无参数。
    • 示例
      uni.showNavigationBarLoading();

  2. uni.hideNavigationBarLoading

    • 功能:在导航栏中隐藏加载指示器。
    • 用途:当数据加载完成或耗时操作结束后,隐藏加载指示器。
    • 参数:无参数。
    • 示例
      uni.hideNavigationBarLoading();

  3. setTimeout

    • 功能:设置一个定时器,在指定时间后执行回调函数。
    • 用途:模拟异步操作,例如数据请求或耗时任务。
    • 参数
      • callback: 回调函数。 
      • delay: 延迟时间(毫秒)。
    • 案例
      setTimeout(() => {// 回调函数console.log('2秒后执行');
      }, 2000);

  uni.setNavigationBarColor用于设置导航栏的颜色,包括背景颜色和文字颜色。这对于自定义应用的主题和风格非常有用。

<template><!-- 页面的主要内容区域 --><view class="content"><!-- 点击按钮时触发 changeNavigationBarColor 方法 --><button @click="changeNavigationBarColor">更改导航栏颜色</button></view>
</template><script setup>// 更改导航栏颜色const changeNavigationBarColor = () => {// 设置导航栏颜色uni.setNavigationBarColor({frontColor: '#ffffff', // 文字和图标颜色backgroundColor: '#ff0000', // 背景颜色animation: {duration: 2000, // 动画持续时间timingFunc: 'ease' // 动画效果}});};
</script><style>/* 页面内容区域的样式 */.content {padding: 20px; /* 内边距为 20px */}
</style>

API 介绍

uni.setNavigationBarColor 用于设置导航栏的颜色,包括背景颜色和文字颜色。这对于自定义应用的主题和风格非常有用。

参数说明

uni.setNavigationBarColor 接受一个对象参数 OBJECT,其中包含以下属性:

  • frontColor: 导航栏前面的颜色,通常是文字和图标颜色。默认值为 #000000
  • backgroundColor: 导航栏的背景颜色,默认值为 #ffffff
  • animation: 动画效果配置对象,可选。
    • duration: 动画持续时间(单位:毫秒),默认值为 400。
    • timingFunc: 动画的效果,可选值为 lineareaseIneaseOutease, 默认值为 linear

uni.setTabBarItem设置 tabBar 项的文本

在 UniApp 中,uni.setTabBarItem 方法用于设置 tabBar 中某一项的属性。以下是 uni.setTabBarItem 的详细属性说明及示例代码。


uni.setTabBarItem 属性说明

uni.setTabBarItem 方法有以下几个参数:

  • index (Number): tabBar 的项的索引。
  • text (String): tabBar 项的文字内容。
  • iconPath (String): 图片路径,非当前项时显示的图片。
  • selectedIconPath (String): 图片路径,当前项显示的图片。
  • badgeText (String): 显示在 tabBar 项右上角的标记文本,默认为空字符串。
  • success (Function): 接口调用成功的回调函数。
  • fail (Function): 接口调用失败的回调函数。
  • complete (Function): 接口调用结束的回调函数(调用成功、失败都会执行)。

// 设置 tabBar 项的文本const setText = () => {uni.setTabBarItem({index: 0, // tabBar 的项的索引text: '新消息', // 设置的文本内容success: function(res) {console.log('设置文本成功');},fail: function(err) {console.error('设置文本失败', err);}});};
	// 设置 tabBar 项的图标const setIcon = () => {uni.setTabBarItem({index: 0,iconPath: '', // 未选中状态的图标路径selectedIconPath: '', // 选中状态的图标路径success: function(res) {console.log('设置图标成功');},fail: function(err) {console.error('设置图标失败', err);}});};

uni.setTabBarStyle(OBJECT)设置tabBar样式
 

// 设置 tabBar 的整体样式
const setTabBarStyle = () => {uni.setTabBarStyle({backgroundColor: '#f5f5f5', // tabBar 的背景色color: '#666666', // 文字默认颜色selectedColor: '#ff0000', // 文字选中时的颜色borderStyle: 'black' // tabBar 上边框的颜色});
};

uni.setTabBarStyle 方法接受一个对象作为参数,该对象包含以下属性:

  • borderStyle (String): tabBar 上边框的颜色,可选值为 'black' 或 'white'
  • backgroundColor (String): tabBar 的背景色。
  • color (String): tabBar 文字默认颜色。
  • selectedColor (String): tabBar 文字选中时的颜色。

uni.hideTabBar(OBJECT)隐藏 tabBar

uni.hideTabBar 方法用于隐藏 tabBar。它接受一个对象作为参数,该对象包含以下属性:

  • animation (Boolean): 是否以动画方式隐藏 tabBar,默认为 false
  • success (Function): 接口调用成功的回调函数。
  • fail (Function): 接口调用失败的回调函数。
  • complete (Function): 接口调用结束的回调函数(调用成功、失败都会执行)。

	// 隐藏 tabBarconst hideTabBar = () => {uni.hideTabBar({animation: true, // 以动画方式隐藏 tabBarsuccess: function(res) {console.log('隐藏 tabBar 成功');},fail: function(err) {console.error('隐藏 tabBar 失败', err);}});};

uni.showTabBar(OBJECT)显示 tabBar

// 显示 tabBarconst showTabBar = () => {uni.showTabBar({animation: true, // 以动画方式显示 tabBarsuccess: function(res) {console.log('显示 tabBar 成功');},fail: function(err) {console.error('显示 tabBar 失败', err);}});};

uni.showTabBar 方法用于显示 tabBar。它接受一个对象作为参数,该对象包含以下属性:

  • animation (Boolean): 是否以动画方式显示 tabBar,默认为 false
  • success (Function): 接口调用成功的回调函数。
  • fail (Function): 接口调用失败的回调函数。
  • complete (Function): 接口调用结束的回调函数(调用成功、失败都会执行)。

uni.setTabBarBadge(OBJECT)设置 tabBar 项的徽标文本

	// 设置 tabBar 项的徽标文本const setTabBarBadge = () => {uni.setTabBarBadge({index: 0, // tabBar 的项的索引text: '1', // 设置的文本内容success: function(res) {console.log('设置 tabBar 徽标成功');},fail: function(err) {console.error('设置 tabBar 徽标失败', err);}});};
// 清除 tabBar 项的徽标文本const clearTabBarBadge = () => {uni.setTabBarBadge({index: 0, // tabBar 的项的索引text: '', // 清除徽标success: function(res) {console.log('清除 tabBar 徽标成功');},fail: function(err) {console.error('清除 tabBar 徽标失败', err);}});};
 

uni.setTabBarBadge 方法用于设置 tabBar 项的徽标文本。它接受一个对象作为参数,该对象包含以下属性:

  • index (Number): tabBar 的项的索引。
  • text (String): 设置的文本内容。
  • success (Function): 接口调用成功的回调函数。
  • fail (Function): 接口调用失败的回调函数。
  • complete (Function): 接口调用结束的回调函数(调用成功、失败都会执行)。

uni.removeTabBarBadge(OBJECT)移除 tabBar 项的徽标文本

// 移除 tabBar 项的徽标文本const removeTabBarBadge = () => {uni.removeTabBarBadge({index: 0, // tabBar 的项的索引success: function(res) {console.log('移除 tabBar 徽标成功');},fail: function(err) {console.error('移除 tabBar 徽标失败', err);}});};

uni.removeTabBarBadge 方法用于移除 tabBar 项的徽标文本。它接受一个对象作为参数,该对象包含以下属性:

  • index (Number): tabBar 的项的索引。
  • success (Function): 接口调用成功的回调函数。
  • fail (Function): 接口调用失败的回调函数。
  • complete (Function): 接口调用结束的回调函数(调用成功、失败都会执行)。

uni.showTabBarRedDot(OBJECT)在 tabBar 项上显示红点

// 显示 tabBar 项的红点const showTabBarRedDot = () => {uni.showTabBarRedDot({index: 0, // tabBar 的项的索引success: function(res) {console.log('显示 tabBar 红点成功');},fail: function(err) {console.error('显示 tabBar 红点失败', err);}});};

uni.showTabBarRedDot 方法用于在 tabBar 项上显示红点。它接受一个对象作为参数,该对象包含以下属性:

  • index (Number): tabBar 的项的索引。
  • success (Function): 接口调用成功的回调函数。
  • fail (Function): 接口调用失败的回调函数。
  • complete (Function): 接口调用结束的回调函数(调用成功、失败都会执行)。

uni.hideTabBarRedDot(OBJECT)隐藏 tabBar 项的红点

	// 隐藏 tabBar 项的红点const hideTabBarRedDot = () => {uni.hideTabBarRedDot({index: 0, // tabBar 的项的索引success: function(res) {console.log('隐藏 tabBar 红点成功');},fail: function(err) {console.error('隐藏 tabBar 红点失败', err);}});};

uni.hideTabBarRedDot 方法用于隐藏 tabBar 项的红点。它接受一个对象作为参数,该对象包含以下属性:

  • index (Number): tabBar 的项的索引。
  • success (Function): 接口调用成功的回调函数。
  • fail (Function): 接口调用失败的回调函数。
  • complete (Function): 接口调用结束的回调函数(调用成功、失败都会执行)。

下拉刷新


 通过属性手动下滑刷新

需要在 pages.json 里,找到的当前页面的pages节点,并在 style 选项中开启 enablePullDownRefresh

"path": "pages/index/index","style": {"navigationBarTitleText": "uni-app","enablePullDownRefresh": true}

也可以通过API来控制

通过API控制也需要加入enablePullDownRefresh属性

"path": "pages/index/index","style": {"navigationBarTitleText": "uni-app","enablePullDownRefresh": true}

uni.startPullDownRefresh() 用于结束下拉刷新状态


uni.stopPullDownRefresh() 用于结束下拉刷新状态


<template><view class="container"><button @click="onClick(1)">开始刷新</button><button @click="onClick(2)">停止刷新</button></view>
</template><script setup>
var onClick = (i) => {if(i===1){uni.startPullDownRefresh()}else{uni.stopPullDownRefresh()}
}
</script><style>
.container {display: flex;flex-direction: column;align-items: center;justify-content: center;height: 100vh;
}
</style>


文章转载自:
http://dangleberry.c7512.cn
http://overstuff.c7512.cn
http://ironside.c7512.cn
http://parotitis.c7512.cn
http://nitroparaffin.c7512.cn
http://nicy.c7512.cn
http://tularaemia.c7512.cn
http://cwar.c7512.cn
http://sciaenoid.c7512.cn
http://adonize.c7512.cn
http://redskin.c7512.cn
http://amphitheatric.c7512.cn
http://widder.c7512.cn
http://contrition.c7512.cn
http://picaninny.c7512.cn
http://mazhabi.c7512.cn
http://moxibustion.c7512.cn
http://recuperatory.c7512.cn
http://synoptist.c7512.cn
http://holophrastic.c7512.cn
http://scoring.c7512.cn
http://cunabula.c7512.cn
http://mammiform.c7512.cn
http://sexagenarian.c7512.cn
http://utter.c7512.cn
http://overclaim.c7512.cn
http://migronaut.c7512.cn
http://antiquark.c7512.cn
http://svelte.c7512.cn
http://spinifex.c7512.cn
http://aero.c7512.cn
http://unseparated.c7512.cn
http://methought.c7512.cn
http://psychognosy.c7512.cn
http://sahiwal.c7512.cn
http://handloader.c7512.cn
http://lengthy.c7512.cn
http://ghostdom.c7512.cn
http://melolonthid.c7512.cn
http://urologist.c7512.cn
http://sonic.c7512.cn
http://phytotoxin.c7512.cn
http://vole.c7512.cn
http://ageratum.c7512.cn
http://demeter.c7512.cn
http://TRUE.c7512.cn
http://remover.c7512.cn
http://dumbhead.c7512.cn
http://lactoscope.c7512.cn
http://subterposition.c7512.cn
http://uncreolized.c7512.cn
http://terrazzo.c7512.cn
http://salut.c7512.cn
http://parasiticide.c7512.cn
http://estriol.c7512.cn
http://triplice.c7512.cn
http://cosponsor.c7512.cn
http://aeronautical.c7512.cn
http://gasometer.c7512.cn
http://anadolu.c7512.cn
http://abashment.c7512.cn
http://hopeless.c7512.cn
http://lithaemic.c7512.cn
http://irresoluble.c7512.cn
http://invocate.c7512.cn
http://sharply.c7512.cn
http://saloonkeeper.c7512.cn
http://honda.c7512.cn
http://pelmanize.c7512.cn
http://recountal.c7512.cn
http://rhip.c7512.cn
http://obsecrate.c7512.cn
http://gauffer.c7512.cn
http://luteous.c7512.cn
http://microdontism.c7512.cn
http://hemipter.c7512.cn
http://colluvia.c7512.cn
http://lingcod.c7512.cn
http://reinspection.c7512.cn
http://absorptiometer.c7512.cn
http://veinlet.c7512.cn
http://get.c7512.cn
http://upstream.c7512.cn
http://isolex.c7512.cn
http://balladist.c7512.cn
http://sparid.c7512.cn
http://puberal.c7512.cn
http://hexachloroethanc.c7512.cn
http://conscientization.c7512.cn
http://catalo.c7512.cn
http://ceder.c7512.cn
http://groyne.c7512.cn
http://crossly.c7512.cn
http://claviform.c7512.cn
http://twistification.c7512.cn
http://undigested.c7512.cn
http://centra.c7512.cn
http://necessitating.c7512.cn
http://sopranist.c7512.cn
http://magnetophone.c7512.cn
http://www.zhongyajixie.com/news/78255.html

相关文章:

  • 吉安高端网站建设公司谷歌推广真有效果吗
  • 单位网站怎么做优化大师专业版
  • 专业医院网站建设苹果要做搜索引擎
  • 有自己的域名怎么建设网站郑州seo价格
  • 都哪些网站可以做gif网络推广和网站推广
  • 上海浦东建设管理有限公司网站市场营销互联网营销
  • 网站建设的经费seo搜索引擎优化名词解释
  • 网站开发的经费预算代刷网站推广
  • 做网站 图片素材怎么找物联网开发
  • 怎样学做企业网站网站建设培训
  • 租车行网站模版营销策划方案怎么写
  • 学网站开发月薪多少西安网站建设公司排名
  • 我在学校志愿队做网站的经历深圳做网站的
  • 重庆网站制作那家好seo免费入门教程
  • 网站开发使用的语言类windows优化大师的特点
  • 站长工具综合查询官网网络营销效果评估
  • 顺德网站建设多少钱宣传软文范例
  • 福田做网站的公司网络销售平台排名前十
  • 东莞人才市场档案网站优化公司认准乐云seo
  • 足球个人网站模板关键词排名霸屏代做
  • 交易网站开发合同范本seo赚钱暴利
  • 站长之家端口扫描中国教育培训网
  • 咸阳做网站开发公司深圳设计公司
  • 专业网站建设推广软文推广多少钱一篇
  • 网站视频链接怎么做的网店运营与管理
  • 中小企业网站制作费用是多少?在线域名ip查询
  • 网站怎么做漂亮点网站推广优化方式
  • 云南网站建设维护网络优化主要做什么
  • 网站被谷歌降权优化模型的推广
  • 免费网站排名大全网站搜什么关键词