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

205
Views
apply function from methods to reverse string in paragraph in vue.js

Dears, I have tried to apply function to reverse string in paragraph text in vue.js, I have created function to reverse words in methods called (reverseword) and added it

card using :rule="reverseword()",but it does not work. your support is highly appreciated Code:

    <div class="post-box">
        <span class="post-viwes">{{viwes}}</span>
        <h3 class="post-title">{{title}}</h3>       
         <span class="post-date">{{date}}</span>
        <p class="post-content">{{content}}</p>
        <div class="row">
            <div class = "col-sm-6 text-right">
              <span class="post-author">{{author}} </span>
            </div>
            <div class = "col-sm-6 text-right" :rules="reverseword()">
              <span class="post-category"  >{{category.toUpperCase()}}</span>
            </div>
        </div>
        )
    </div>
</template>
<script>
export default {
    props:["viwes","title","date","content","author","category"],
    name:"posts",
      methods: {
        reverseWord: function () {
          this.category = this.category.split('').reverse().join('')
    }   
}};
</script>```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your reverseWord method attempts to mutate a prop (category).
You can't mutate a prop, because the mutation would be overwritten by the first update from the parent.

If/when you do want/need to change a prop value, you have do it in the parent component which will then pass the change down to the child component, through the props binding.

Updating the parent from child can be done by

  • either using $emit
  • or by using a store, external to both the child and the parent.

If, in fact, you don't want to mutate category, you just need to be able to use its reverse inside the template, create a computed property:

computed: {
  reversedCategory() {
    return this.category.split('').reverse().join('');
  }
}

Use it in template as you would use a normal property:

 <div class = "col-sm-6 text-right" :rules="reversedCategory">
   <span class="post-category"  >{{category.toUpperCase()}}</span>
 </div>

The computed is reactive. Meaning every time category changes, reverseCategory will update accordingly.

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!