--- title: Notification.dir slug: Web/API/notification/dir translation_of: Web/API/Notification/dir ---

{{APIRef("Web Notifications")}}

{{domxref("Notification")}} 的`dir`是一个只读属性,它表示Notification中显示的文本方向 会{{domxref("Notification.Notification","Notification()")}} 构造函数里制定的`dir` 属性的值来设定。

{{AvailableInWorkers}}

语法

var direction = Notification.dir;

一个表示文本方向的{{domxref("DOMString")}}变量。 可能的取值为:

提示:似乎大多数浏览器都忽略了明确的LTR 和RTL 设置,要按照与浏览器的通用设置来操作。

例子

The following snippet fires a notification; a simple options object is created, then the notification is fired using the Notification() constructor.

var options = {
  body: '你去过新疆吗?',
  dir: 'rtl'
}

var n = new Notification('测试通知',options);

n.dir // 应该返回 'rtl'

规则

规则 状态 注释
{{SpecName('Web Notifications','#dom-notification-dir','dir')}} {{Spec2('Web Notifications')}} Living standard

浏览器兼容性

{{Compat("api.Notification.dir")}}

参见