Taro-navigation-bar icon indicating copy to clipboard operation
Taro-navigation-bar copied to clipboard

在NavBar中赋值back = {true} home = {true}导航条不显示back与home图标

Open yjj891896039 opened this issue 5 years ago • 13 comments

在NavBar中赋值back = {true} home = {true}导航条不显示back与home图标,请问这个问题怎么解决

yjj891896039 avatar Aug 28 '19 02:08 yjj891896039

demo例子中会出现吗?如果例子没问题请严格按照例子的配置来操作.或者还有问题的话请提供一下代码和环境最好

lingxiaoyi avatar Aug 28 '19 02:08 lingxiaoyi

我发现components文件夹下的navbar_lxy的index的208行多了一个'}',然后我把它删了。demo的例子我是在github下载完全没有动过的呀

yjj891896039 avatar Aug 28 '19 02:08 yjj891896039

`import Taro, { Component } from '@tarojs/taro'; import { View } from '@tarojs/components'; import NavBar from '@components/navbar_lxy'; import withComponent from './mixin'; import './index.scss';

@withComponent export default class Index extends Component { config = { navigationBarTitleText: '', navigationStyle: 'custom' };

state = {}; handlerGobackClick() { const pages = Taro.getCurrentPages(); if (pages.length >= 2) { Taro.navigateBack({ delta: 1 }); } else { Taro.navigateTo({ url: '/pages/index/index' }); } } render() { return ( <View className='main-wraper'> <NavBar title='有返回和home' background='#fff' back = {true} home = {true} onBack={this.handlerGobackClick} onHome={this.handlerGohomeClick} /> <View className='main'> <View className='p'>有返回和home的页面</View> </View> </View> ); } } ` 这是demo2的代码

yjj891896039 avatar Aug 28 '19 02:08 yjj891896039

<NavBar title='有返回和home' background='#fff' back = {true} home = {true} onBack={this.handlerGobackClick} onHome={this.handlerGohomeClick} />

yjj891896039 avatar Aug 28 '19 02:08 yjj891896039

你确定你是在demo里出现的问题吗?我刚才打开怎么没问题

lingxiaoyi avatar Aug 28 '19 02:08 lingxiaoyi

对呀,我把在demo中的NavBar把back = {true} home = {true},导航条没有显示返回和Home图标

yjj891896039 avatar Aug 28 '19 03:08 yjj891896039

<NavBar title='有返回和home' background='#fff' back home onBack={this.handlerGobackClick} onHome={this.handlerGohomeClick} />

lingxiaoyi avatar Aug 28 '19 03:08 lingxiaoyi

这个back 和home不能赋值的吗

yjj891896039 avatar Aug 28 '19 03:08 yjj891896039

按道理可以的啊,但是taro组件需要这样写比较好

lingxiaoyi avatar Aug 28 '19 03:08 lingxiaoyi

默认是false,写个字段就代表true,不需要你手动去赋值

lingxiaoyi avatar Aug 28 '19 03:08 lingxiaoyi

改成

<NavBar title='有返回和home' background='#fff' back home onBack={this.handlerGobackClick} onHome={this.handlerGohomeClick} />也不显示哦... 可以加你的微信私聊吗

yjj891896039 avatar Aug 28 '19 03:08 yjj891896039

那你加我微信

lingxiaoyi avatar Aug 28 '19 03:08 lingxiaoyi

zhijunxh

lingxiaoyi avatar Aug 28 '19 03:08 lingxiaoyi