我通过此配置为 .jsx
文件启用 web-mode
。
(add-to-list 'auto-mode-alist '("\\.jsx$". web-mode))
但是,当我的 react 文件具有 .js
扩展名时,此操作会失败。 web-mode
无法将内容类型关联为 jsx
。
它说:
The var
web-mode-content-types-alist
can be used to associate a file path with a content type
但我不想指定文件路径。
我想使用迷你缓冲区或更好的自动检测来关联内容类型。
最佳答案
你可以使用
(setq web-mode-content-types-alist '(("jsx". "/some/react/path/*\\.js[x]?\\'")))
或者,如果您不想检测每个 js 文件的 jsx
(setq web-mode-content-types-alist '(("jsx". "\\.js[x]?\\'")))
关于javascript - 如何使用 minibuffer 设置 React js 文件的 web-mode-content-type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31020635/