1

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. Commented Jun 22, 2019 at 10:52

1 Answer 1

2

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.

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

Comments

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.