1
@extends('layouts.app')
@section('body')
    <div class="general_wrapper" id="profile">
        @component('components.nav.main')
            @slot('menu')
                <div class="nav_menu">
                    <ul>
                        <li :class="{'active': tab==0}" @click="tabSelect(0)">
                           item0
                        </li>
                        <li :class="{'active': tab==1}" @click="tabSelect(1)">
                           item1
                        </li>
                    </ul>
                </div>
            @endslot
        @endcomponent
    </div>
@endsection
@section('script')
    <script>
        const profile = new Vue({
            el: '#app',
            data: {
                tab: 0
            },
            methods: {
                tabSelect(id) {
                    profile.tab = id;
                }
            }
        });
    </script>
@endsection

I need this bunch of code inside my project. I don't know what wrong with it. I got this error:

Property or method "tab" is not defined on the instance but referenced during render.

I removed 'const app = new Vue({ el: '#app'});' from app.js it works, but I have another Vue component in my project, and this made another one unknown...

1

1 Answer 1

2

You need to define a container for you app

For eg.

<div id="app"> 
  Inside your vue component
</div>

so you can defina a vue component that use the container used in el setting

el: '#app',

maybe you will have some problem between blade and vue tags {{}}. Maybe you will can use @{{}} to specify vue vars

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

3 Comments

My buddy, I defined it in app.js. I removed 'const app = new Vue({ el: '#app'});' from app.js it works, but I have another Vue component in my project, and this made another one unknown...
You should declare the components to use en you main.js or app.js vue component... for eg. Vue.component('question', require('./components/questions/Question.vue'));
tnx buddy, I have problem in defining components, but now there is another issue: stackoverflow.com/questions/53887003/…

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.