[英]How to render elasticsearch json info as clickable links with Vue.js
Hey there folks :) I am trying to set up a search engine with elasticsearch/node.js, express and vue.js. 嘿那里大家:)我正在尝试用elasticsearch / node.js,express和vue.js建立一个搜索引擎。 I would like the search results to be clickable links, but they are only returning non-clickable html.
我希望搜索结果是可点击的链接,但它们只返回不可点击的html。 I have tried adding normal html A- tags to the .json file, but on the front end this renders as a non clickable html text and not as a clickable link.
我已经尝试将普通的html A-标签添加到.json文件中,但是在前端,这将呈现为不可点击的html文本,而不是可点击的链接。 Any suggestions would be really appreciated this is what I have tried, just as a test:
任何建议都会非常感激,这就是我尝试过的,就像测试一样:
<a href="https://www.w3schools.com/html/">Visit our HTML tutorial</a>
I have had a look on google for possible solutions but all I could find were references to the normal html a-tag and that both j.son and vue.js can take those? 我在google上看过可能的解决方案,但我能找到的只是对普通html a-tag的引用,j.son和vue.js都可以参考吗?
If I correctly get the issue, At FE your link get rendered as sting which is <a href="google.com">Google </a>
. 如果我正确地解决了问题,请在FE处将您的链接呈现为
<a href="google.com">Google </a>
。 You need to use v-html
in this case to tell element to render the passed value as html
not as string
在这种情况下,您需要使用
v-html
来告诉元素将传递的值呈现为html
而不是string
//Suppose you have this vue data prop
let url = <a href="google.com">Google </a>
Now In you html part Just use v-html
to render 现在在你的HTML部分只需使用
v-html
进行渲染
<div class="foo">
<template v-html="url" />
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.