woocommerce/packages/js/data/zh-cn/README.md
2026-04-15 10:18:01 +08:00

37 lines
No EOL
985 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 数据
WooCommerce 管理员数据存储和实用工具。
## 安装
安装模块
```bash
pnpm install @woocommerce/data --save
```
_此包假定您的代码将在 **ES2015+** 环境中运行。如果您使用的环境对 ES2015+ 支持有限或不支持(例如较低版本的 IE那么使用 [core-js](https://github.com/zloirock/core-js) 或 [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) 将为这些方法添加支持。在 [Babel 文档](https://babeljs.io/docs/en/next/caveats) 中了解更多信息。_
## 用法
```JS
import { settingsStore } from '@woocommerce/data';
import { useSelect } from '@wordpress/data';
function MySettings() {
const settings = useSelect( select => {
return select( settingsStore ).getSettings('general').general;
} );
return (
<ul>
{ Object.keys( settings ?? {} ).map( setting => (
<li key={ setting }>{ setting }</li>
) ) }
</ul>
);
}
// 在应用程序中渲染:
//
// <MySettings />
```