Closed naingyy closed 6 years ago
Hi, To access setting on the javascript side you should add this in your global scope like laravel does.
// layout.blade.php
<head>
<title>@yield('title', 'Settings')</title>
<script>
window.App = {!! json_encode([
'settings' => \setting()->all(),
'anyOtherThings' => []
]); !!}
</script>
</head>
Now in your vue component, you can access it App.settings.app_name
.
It will be best to define some computed property on the root component and access these global App namespace from there.
const app = new Vue({
el: '#app',
computed: {
myApp() {
return window.App;
}
}
});
// access it
myApp.settings.app_name
Thanks @saqueib
Nice solution.I love this solutions.
!Thanks
Hi , Thanks for your great package. I want to ask is which is the best to access setting from javascript. I mean form app.js file or vuejs component.
Thanks!