reactjs - 如何在 PhpStorm 中为 WordPress Gutenberg 创建 React.js 文件
问题描述
所以我正在学习如何使用古腾堡,.jsx
我相信很多这些教程都在展示他们的代码。我已经做了很多查找,但不确定我是否做对了。
我尝试使用 TypeScript 文件,当我在其中粘贴 React 代码时,它会询问我是否要切换到 React 文件格式。我说是的,它会创建一个.jsx
文件,然后编译成一个.js
文件。
但是,我在 WordPress 中粘贴的代码给了我一个错误:
无效的正则表达式:缺少 /
我不确定我是否正确设置了文件,或者我做错了什么。我在下面粘贴了我的代码
.JSX
const { registerBlockType } = wp.blocks;
registerBlockType('base-theme/tile-block', {
title: "Tile Block",
icon: 'welcome-write-blog',
category: 'common',
edit() {
return (
<div>Only the editor will show this</div>
);
},
save() {
return (
<div>Only the front end will show this</div>
);
}
});
.JS 编译
var registerBlockType = wp.blocks.registerBlockType;
registerBlockType('base-theme/tile-block', {
title: "Tile Block",
icon: 'welcome-write-blog',
category: 'common',
edit: function () {
return Only;
the;
editor;
will;
show;
this < /div>;
}
});
save();
{
return Only;
the;
front;
end;
will;
show;
this < /div>;
;
}
;
解决方案
推荐阅读
- shell - 选择从一台服务器到另一台服务器的 shell 脚本
- python - Python - 在字典中使用以前的值
- travis-ci - Travis Platformio,未运行 test_main.cpp
- python - python :: MySQLdb 连接失败,但 pymysql 没有。为什么?
- android - 自定义字体在 android 中不起作用(react native 0.57.4)
- visual-studio-code - 如何正确处理多根工作区中的断点?
- android - 在 com.google.android.gms.ads.internal.video 崩溃
- mysql - 如何使用 JOIN 语句按 DESC 排序?
- azure - 如何在.net core api 1中为单个请求发送多个响应
- elm - 无法发布包 - 我无法发布 2.0.0 作为初始版本