Hi guys I tried to use VueJS on Laravel without using component, but face an error.
[Vue warn]: Property or method "message" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property
Inside laravel app.js there is default VueJS instance
const app = new Vue({
el: '#app'
});
So this is my html code for test.blade.php
<div id="app">
<div id="test" class="">
@{{ message }}</h3>
</div>
</div>
<script>
new Vue({
el: '#test',
data: {
message: 'Hello Vue!'
}
})
</script>
From the code, the div #test is inside the div #app (default laravel vue instance).
If I comment out the default laravel app vuejs instance, the problem is gone.
My question is:
Do nested instance is prohibited or I was doing it wrong? How to properly declare Vue instance on individual blade page?
Is it safe to comment out the default Vue instance from Laravel? Or will it affected others vue component inside Laravel?
Thanks
--
Edit:
Found similar question with good answer, so I am closing this.
Edit 2:
Here is the best solution if you want to utilize the power of Blade but still enjoy reactive of VueJS