我有一个要显示在Vue组件中的给定HTML字符串。
上下文:KaTeX是一个排版库,可将数学语法呈现为易于阅读的方程式。
以下是字符串:
<p>A pintail population, <div v-katex="'p'"></div>, of <div v-katex="'1000'"></div> bacteria tows in number according to the equation <div v-katex="'\\displaystyle p(t) = 1000(1 + \\frac{4t}{t^2+ 50})'"></div>, where <div v-katex="'t'"></div> is in hours. Find the rate which the population is growing after <div v-katex="'1 h'"></div> and after <div v-katex="'2h'"></div>.</p>
这里是我的代码: renderKatex()返回HTML代码的字符串。
这是在网络浏览器开发工具中:
但是在这里显示:
如您所见,<div v-katex>
元素未显示。除此以外,当我在模板中对以前的HTML进行硬编码(我从dev-tools复制并粘贴了HTML)时,它会显示:
显示:
因此,Vue指令“ v-html”似乎存在一些问题,无法正确呈现元素。