display funtion's result



  • hi! i’m a beginner in the quasar framework , i would know how to display a function’s result , this is my code source

    <template>

    <div>

    <div class="layout-padding">
      <p class="caption">
        La durée de l'emprunt en mois
        <span class="label inline bg-secondary text-white">
          <span class="right-detail"><em>{{value1}}</em> &nbsp;&nbsp;mois</span>
        </span>
      </p>
        
      <q-range v-model="value1" :min="0" :max="300" :step="1" label></q-range>
      
      <p class="caption">
        Le montant emprunté (€)
        <span class="label inline bg-secondary text-white">
          <span class="right-detail"><em>{{value2}}</em> &nbsp;&nbsp;€</span>
        </span>
      </p>
        
      <q-range v-model="value2" :min="0" :max="500000" :step="10" label></q-range>
      
      <p class="caption">
        TEG : Taux Effectif Global annuel
        <span class="label inline bg-secondary text-white">
          <span class="right-detail"><em>{{value3}}</em> &nbsp;&nbsp;%</span>
        </span>
      </p>
        
      <q-range v-model="value3" :min="0" :max="100" :step="0.1" label></q-range>
    

    <p class=“caption”>Mensualité</p>
    <span class=“right-detail” ><em>{{total}}</em> €</span>

    </div>
    

    </div>
    </template>

    <script>
    export default {
    data () {
    return {
    value1: 0,
    value2: 0,
    value3: 0,

    computed: {
    total: function(value1,value2,value3) {
    return (value2*(value3/1200))/(1-Math.pow((1+value3/1200),(-value1)))
    } } } } }
    </script>



  • @zeineb If what you posted for your <script> tag is correct, then:

    • Your curly braces are out of place
    • In your call to total, you’re not supplying the parameters. Instead our total function won’t take any parameters and will instead use this.foo to get the value of foo.
    • You can’t use -foo to get the negative value of foo
    <script>
      export default {
        data () {
          return {
            value1: 0,
            value2: 0,
            value3: 0,
    
      computed: {
        total: function(value1,value2,value3) {
          return (value2*(value3/1200))/(1-Math.pow((1+value3/1200),(-value1)))
      } } } } }
    </script>
    

    can be converted into

    <script>
      export default {
        data () {
          return {
            value1: 0,
            value2: 0,
            value3: 0,
          }
        },
        computed: {
          total () {
            return (this.value2 * (this.value3 / 1200)) / (1 - Math.pow((1 + this.value3 / 1200), ( this.value1 * -1)))
          }
        }
      }
    </script>
    

    Also, you posted this in Show & Tell. I think a better category would have been Help. And please format the code you post here so it’s easier for people to help you.

    ```
    console.log(‘Hello World’)
    ```

    turns into

    console.log('Hello World')
    

Log in to reply
 

Looks like your connection to Quasar Framework was lost, please wait while we try to reconnect.