为什么$ app-direction:rtl不起作用?

Ric*_*evi 3 typescript ionic2 ionic3 angular

文件:https//ionicframework.com/docs/theming/rtl-support/

我不知道为什么这个变量$app-direction: rtl;/src/theme/variables.scss不工作/有没有影响?

ionic --version
3.6.0
Run Code Online (Sandbox Code Playgroud)

用户界面是一样的,有或没有。

根据文档,他们指出$ app-direction设置在./node_modules/ionic-angular/themes/ionic.globals.scss文件中的某个位置。至少对我来说-没有这样的变量...据我所知-我使用的是最新版本no?

seb*_*ras 5

AFAIK,$app-direction: rtl;应该放在variables.scss文件中,而变量唯一要做的就是

启用对RTL语言的支持

这具有使生成的CSS保持较小的优点。

但这并不能使您的应用成为RTL。如果您想更改应用程序的布局以使其成为RTL,就像您可以在docs中看到的那样

我们建议应用程序的index.html文件已经设置了正确的dir属性值,例如<html dir="ltr"><html dir="rtl">

如果您需要动态更改它,则可以使用中的setDir(dir, updateDocument)方法Platform,如下所示:

private setProperAligment(): void {

    if (this.selectedLanguage.rtl) {
        this.platform.setDir('rtl', true);
        // ...
    } else {
        this.platform.setDir('ltr', true);
        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)