Skip to content
Related Articles

Related Articles

How to change text into lower case string using filters in Vue.js ?
  • Last Updated : 23 Feb, 2021

Vue is a progressive framework for building user interfaces. The core library is focused on the view layer only and is easy to pick up and integrate with other libraries. Vue is also perfectly capable of powering sophisticated Single-Page Applications in combination with modern tooling and supporting libraries.

Filters are a functionality provided by Vue components that let you apply formatting and transformations to any part of your template dynamic data. The filter property of the component is an object. A single filter is a function that accepts a value and returns another value. The returned value is the one that’s actually printed in the Vue.js template.

To lowercase string using filters, we have to write logic to convert a regular string into all lower case and apply the filter on a required string.

Example 1:

index.html




<!DOCTYPE html>
<html lang="en">
  
<head>
    <script src=
    </script>
  
    <script src='app.js'></script>
</head>
  
<body>
    <div id='parent'>
  
        <p>
            <strong>Name : </strong
            {{ name | lowerCased }}
        </p>
  
  
        <p>
            <strong>Details : </strong
            {{ details | lowerCased }}
        </p>
    </div>
</body>
  
</html>

app.js:

Javascript




const parent = new Vue({
    el : '#parent',
    data : {
        name : "Rinkle ROY",
        details: "Simply duMMy TEXT OF THE PRINTING
            and tyPesETTing industry.\
            Lorem Ipsum has BEEN the industry'S 
            Standard DUMMY text EVER sINCE the 1500s,\
            when An UNknown pRInter took a gAlley 
            of type and scrambled it to make a type\
            specimen book. It has suRVIVed not 
            oNLy five centurIES, but also the leAP into \
            electronic tyPestting, remaINIng 
            eSSEntially unchanGED"
    },
  
    filters:{
        lowerCased : function(data){
            lower = []
            data.split(' ').forEach(word => {
                lower.push(word.toLowerCase())
            })
            return lower.join(' ')
        }
    }
})

Output :

Lower casing string using filters

full-stack-img




My Personal Notes arrow_drop_up
Recommended Articles
Page :