question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using filters inside attributes with Vue 2.0

See original GitHub issue

Both of the following work in Vue 1:

<a href="{{ 'something' | linkHandler }}">link</a>
<a :href="'something' | linkHandler">link</a>

Neither of them work in Vue 2.0, because you can only use filters inside interpolations, and you can’t use interpolations as attributes anymore.

Any way around this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

32reactions
nghiepdevcommented, Nov 7, 2016

It work with <a :href="$options.filters.linkHandler('somthings')">link</a>

16reactions
yyx990803commented, Nov 1, 2016

This has been discussed extensively during the 2.0 API design thread - please read that thread, most of the arguments have been raised already. Filters were originally to be removed but added back for the most common use case due to community request. It’s not going to change in the foreseeable future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filters - Vue.js
Filters. Vue.js allows you to define filters that can be used to apply common text formatting. Filters are usable in two places: mustache...
Read more >
Using Filters in Vue.js - CSS-Tricks
Filters are an interesting way to deal with data rendering in Vue but are only useful in a small amount of cases.
Read more >
Everything You Should Know About Filters in Vue - Telerik
Learn everything you need to know about Vue.js filters, from how to use them in your Vue.js application to how to create your...
Read more >
Using multiple filters in v-for directive in Vue 2.0 - Stack Overflow
Found the answer from here. Basically, we only need one computed function to return the filtered data for v-for directive, e.g..
Read more >
How to Use VueJS Filters to Write Better Code - LearnVue
Coding a Vue filter should feel extremely familiar. Like defining computed properties or component methods in the Options API, just put them in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found