1

My code is like this :

<script>
    export default{
        props:... ,
        data(){
            return{
                ...
            }
        },
        computed:{
            ...
        },
        methods:{
            filterBySort: function (sort){
                ...
            },
            filterByLocation: function (location){
                ...
            }
        }
    }
</script>

For example, parameter sort = lowest (on the filterBySort method)

I want display value of parameter sort on the filterByLocation

How can I do it?

2 Answers 2

2

If you define variable sort in the data, and you change it in filterBySort method like this: this.sort = lowest, same value will be available in the method filterByLocation as well.

Sign up to request clarification or add additional context in comments.

Comments

0

One of the ways is to set it up in the data properties.

<script>
export default{
    props:... ,
    data() {
        return{
          sort: null,
          location: null
        }
    },
    computed:{
        ...
    },
    methods:{
        filterBySort: function (){
            console.log(this.sort)
        },
        filterByLocation: function (){
            console.log(this.location)
        }
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.