[英]<a> tag appending href to current url instead of linking directly to what is inside of the href
在Vue组件内部,有一些内容是从firebase中提取并导入到表中的,以便可以显示它。 可以说,这些“字段”之一是url。 在数据库中,其结构为{name:“我的链接”,url:“ www.example.com”},并直接放入标签href中。 当该组件加载并且我检查标签时,它说href的值为“ www.example.com”,但是当我单击链接时,它的链接为“ currentURL / www.example.com”。在下面,我已经包含了该标签。 它是标签的一部分,其中对于特定内容类型中的每个字段,都有逻辑决定该字段是哪种类型
<a v-else-if="findFieldType(field.name) === 'url'" :href="filteredContent[index][field.name].link">{{ filteredContent[index][field.name].name }}</a>
该标签应该链接到其href属性(“ www.example.com”)中的内容,而不是将href的值附加到当前URL并链接到该URL(“ myCurrentUrl / www.example.com”)。
使用vue-router时会出现这种情况,因为它的作用是将提供的值附加到当前url,因此我尝试在此处搜索修复程序,但无济于事。 这就是为什么我使用一个标记,以确保vue-router不会弄乱我的链接,并且单击该链接将直接导致href中的内容。
以下是两个示例URI及其组成部分:
foo://example.com:8042/over/there?name=ferret#nose \\_/ \\______________/\\_________/ \\_________/ \\__/ | | | | | scheme authority path query fragment | _____________________|__ / \\ / \\ urn:example:animal:ferret:nose
www.example.com
既不以方案开头,也不以//
相对于当前方案的开头。
因此,它是相对于当前path的URL。
添加方案 (或//
),例如http://www.example.com
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.