Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
How to pass an svg in a ternary operator?

I have a very expansive custom input and one of the customizations is autocomplete functionality. In the interest of not sharing too much, I will just share the bit of the code that is for the suggestion drop down on the autocomplete. I have a suggestions value and a searchHistory value that is based on the cached search history of the user. To differentiate the two I just want to have a clock or some sort of svg in there. I'm able to render an emoji, but that doesn't fit my design theme so I want to use an clock svg from the library I'm using.

How can I pass that SVG in this ternary operator? I've seen people using '<img :src"../something"/>', but that syntax doesn't seem to work for me either.

Any ideas on how/if I can make this happen?

Cheers!

CAutocompleteList.vue

<template>
  <ul>
    <li
      v-for="suggestion in filteredSuggestions"
      :key="suggestion"
      @click="$emit('selectSuggestion', suggestion)"
    >
      {{ suggestion }} {{ searchHistory.includes(suggestion) ? '⏱' : '' }}
    </li>
  </ul>
  <!-- <IconPowerSupplyOne theme="outline" size="100%" fill="#4771FA" /> -->
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue'

export default defineComponent({
  props: {
    filteredSuggestions: { type: Array as PropType<string[]>, required: true },
    searchHistory: { type: Array as PropType<string[]>, required: true },
  },
  emits: ['selectSuggestion'],
  setup() {
    return {}
  },
})
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A ternary shouldn't be used here because HTML elements can't be used in text interpolation.

v-if directive should be used instead:

<svg v-if="searchHistory.includes(suggestion)">
  ...
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!