<el-link> 如何在 v-for 中拼接 href
data() {
return {
baseUrl: process.env.VUE_APP_BASE_API,
}
}<ul
v-for="(content, index) in tag ? item.content.slice(0, 2) : item.content"
:key="index"
style="width:100%;margin:0;margin-left:0px;margin-top:3px"
>
<el-popover placement="right-start" width="230" trigger="click">
<div>
<p style="line-height: 20px;">
<span style="font-size: 14px;">日志标题:{{ content.notice }}</span>
</p>
<p style="line-height: 20px;">
<div style="font-size: 14px;" class="gutter" :title="content.content" >
日志内容:{{ content.content }}
</div>
</p>
<!-- <p style="line-height: 20px;">
<span style="font-size: 14px;">相关附件:{{ content.url }}</span>
</p> -->
<p style="line-height: 20px;">
<span style="font-size: 14px;">
相关附件:
<el-link :href="`${baseUrl}${content.url}`" :underline="false" target="_blank">
<span> {{ content.urlname }} </span>
</el-link>
</span>
</p>
</div>
<el-button type="text" slot="reference">{{ content.notice }}</el-button>
</el-popover>
</ul>${baseUrl}${content.url} 这种写法不能拿到 content.url 的值
看起来是没有问题的,
${baseUrl}${content.url}应该是能够正确拼接出来正确的结果。最好是可以提供一个最小复现,比如我这样的 👉 Playground Demo