1
votes

I'm using a plain PHP site with vue.js and want to import components, As I see import only works for node and vue? Is there a solution? I'm really not that good.

import and require js pages

import settings from 'settings.html';
Vue.component('app-settings', settings);
import Form from 'settings.js';
<script src="https://cdn.jsdelivr.net/npm/vue"></script>

Uncaught SyntaxError: Unexpected identifier

1
I'm sorry for the short description, it really frustrated me because all the tutorials are form the npm vue version. I created a file named settings.js in the assets/js folder. This is also the place for my app.js file where I wanted to include all the components like in the snippet I pasted in here. - Cortex Reader

1 Answers

1
votes

VueJS built on the top of ES6, so vuejs require babel in order to work. Note: I really do not know why you want to use vuejs and plain PHP, you should make a PHP API, API that provides data for front-end, you cannot use PHP and VueJS in one file because of vuejs code must pass on babel. you should make a PHP API (RESTful API or Graphql), and you will fetch data from API to the front by using axios, fetch or Apollo or whatever.