doujiaoben28596 2019-06-22 10:20
浏览 269

导入页面组件替代vue.js

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

</div>
  • 写回答

1条回答 默认 最新

  • duanshan3331 2019-06-22 12:13
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作