【发布时间】:2020-02-28 20:13:36
【问题描述】:
这里我想在我的网站上实现 MathJax,我在一个组件文件中这样编码:
export default ({ pathname, children }) => {
const post = posts.find(post => post.urlPath === pathname)
const title = post ? post.title : "(my website)"
return (
<div>
<Head>
<title>(my website) | {title}</title>
<style>{globalStyles}</style>
</Head>
<div className='contentContainer'>
<SiteTitle isHomepage={pathname === '/'} />
<Header />
{children}
</div>
</div>
)
}
我在<Head></Head>标签中添加了如下代码:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
},
CommonHTML: { matchFontHeight: false }
});
</script>
为方便起见,我需要添加 tex2jax 配置。
我试图运行它。但是,它不起作用
[ error ] ./components/BlogLayout.js
SyntaxError: /home/website/components/BlogLayout.js: Unexpected token, expected "}" (72:15)
70 | <script type="text/x-mathjax-config">
71 | MathJax.Hub.Config({
> 72 | tex2jax: {
| ^
73 | inlineMath: [["\\(","\\)"] ],
74 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
75 | },
\`\`\`
如何运行它?
【问题讨论】:
-
好问题,我也想知道!
-
这能回答你的问题吗? How to add <script> tag using ReactJS?
标签: javascript node.js next.js mathjax