angular - RTL 布局中的 Ionic 2 后退按钮

标签 angular typescript ionic-framework ionic2 ionic3

我要启动一个 Ionic 2 应用程序,它应该是阿拉伯语,所以我需要使用 RTL 布局,我选择了侧边菜单模板

通过以下行将应用程序配置为 RTL 完美地改变了一切的方向,除了后退按钮应该指向正确的方向

<ion-nav #content [root]="rootPage" dir="rtl"></ion-nav>

导航栏现在看起来像这样

enter image description here

在 Ionic 团队关注 RTL 相关问题之前,是否有任何修复方法?

最佳答案

您可以使用平台将对齐方式设置为 RTL (docs),而不是在 ion-nav 中设置 dir 属性

private setProperAligment(): void {

    if (this.selectedLanguage.rtl) {
        this.platform.setDir('rtl', true);
        // ...
    } else {
        this.platform.setDir('ltr', true);
        // ...
    }
}

这会将 dir="rtl" 属性添加到您应用的 html 标记中。正如您所说,Ionic 团队正在努力解决后退按钮的问题,因此与此同时,您可以在 app.scss 文件中添加此 css 样式规则:

html[dir="rtl"] {
    .back-button-icon.icon-md.back-button-icon-md.ion-md-arrow-back {
        transform: rotate(180deg);
    }

    .back-button-icon.icon-ios.back-button-icon-ios.ion-ios-arrow-back {
        transform: rotate(180deg);
        padding: 0 5px;
    }
}

关于angular - RTL 布局中的 Ionic 2 后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44203777/

相关文章:

reactjs - 为什么在没有 Internet 的情况下启动应用程序时没有正确触发 React Native 的 NetInfo?

http - 如何只等待一定时间才能在 Angular 2 中获得 HTTP 请求(GET/POST)的响应?

node.js - 如何保证最新的写入不会被之前的写入覆盖

javascript - Angular JS 中的嵌套 ng-repeat

angular - Ionic 4 - 当我运行 "ionic server"时,出现 [错误] ng 意外关闭(退出代码 1)

Angular 形式 : "No value accessor for ..."

javascript - angular2 日期管道 locale_id 期间

javascript - state.concat 不是函数 - 类型 'ITask' 不是数组类型

css - 如何在 Bootstrap 中使用 colspan

typescript - 如何使用 redux-thunk 和 TypeScript 调度 ThunkAction