keevitaja
3048
6
Vue

Accessing global variables in vue components

Posted 2 years ago by keevitaja

Hello!

I have declared some javascript variables in blade view files like this:

<script>
    var helpers = { 'csrf': 'dsgsdfjsdlkjsdlkfjskd'};
</script>

And i need to use them in vue components:

<template>
    <form id="delete-request" action="{{ url }}" method="post">
        <input type="hidden" name="_token" value="{{ csrf }}">
        <input type="hidden" name="_method" value="DELETE">
    </form>
</template>

<script>
    export default {
        props: ['url'],
        data: ()=> {
            return {
                csrf: helpers.csrf
            }
        }
    }
</script>

How can i do this? The example above is not working....

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.