My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Passing PHP variable to vue.js vue component

Sunny Lord's photo
Sunny Lord
·Aug 8, 2019

Hello,

I am working on a php site where I want to pass a php string variable to be used in a .vue component. Can someone help me wit this?

here is what i have in code: index.php

<?php $foo = 72; ?>

<div id='app'></div> app.js

import App from './views/App'; new Vue({ el: '#app', render: h => h(App) }); App.vue

<template> </template>

<script> export default { name: 'App' , data() { return { foo: '' } } } </script>

<style></style> As you can see in index.php, $foo = 72. I want that 72 value will be pass on to $foo in App.vue

thanks iosman