VUE Directive V-HTML Using Filter Filters Function Examples


2.0 Filters Only Work In Mustache tags and v-bind.

Vue2.0 is no longer supported The filter is used in V-HTML, such as this is used in 1.0:

{{{Option.Title | Highlight}}}


however, it cannot be used now, Vue2.0 filters can now only be applied in {{}} and V-bind.

However, what should I do if I want to use?

Using the global method
Using the COMPUTED attribute

    Using $ Options.Filters
  • PUT YOURHLIGHT INTO METHODS, AND V-HTML = “Highlight (option.title)”

Vue Define Global Method:

Vue.Prototype.Highlight = function (stitle) {// to do};

Then there is this method directly on all components:
  V-html = "highlight (option.title)  

Using computed attribute

 What if I have a filter That Outputs HTML? Do I Have to use a computed proty.  computed properties are the best woman. You get automatic caching. 
Of course, you can use the calculated property computed, return to the native HTML to V-HTML. Use $ options.Filters


  • V-HTML = ” $ Options.Filters.Highlight (option.title) “.
  • This manner is not described in the document, but this is also a reliable method.

YOU CAN SAFELY Rely On That: $ OPTION ARE The Options Passed to The Vue Construction in Is Just JavaScript

The above is the full knowledge point for this introduced for Vue Directive V-HTML, thank you for reading and supporting Tumi Cloud.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment