php - 如何在php刀片视图中添加php旧代码
问题描述
我开始了一个 laravel + vuejs 项目(fontend 和 backend 在同一个项目中)。它基本上是从纯 php-html 项目的迁移。我想知道是否可以只迁移其中的一部分,并整合其余部分。在你回答之后(谢谢:)),这里是 myview.blade.php:
@extends('template')
@section('contenu')
<div id="app">
@php
$path = public_path('myview/oldfile.php');
include($path);
@endphp
</div>
@endsection
现在我有一个问题:
** 第一期 **
我在旧的 php 文件中有这种代码:
<script type="text/javascript" src="./js/jquery-1.7.2.min.js">
但我的模板中也有脚本(包含导航栏和页脚)。然后我当然得到这个错误
[Vue warn]: Error compiling template:
Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <style>, as they will not be parsed.
** 问题 2 **
$.post("./myview.php", "mode=activateForm&id1=<?=$id1?>&id2=<?=$_GET["id2"]?>", function() {
MethodNotAllowedHttpException
The POST method is not supported for this route. Supported methods: GET, HEAD.
新问题是这个,我不明白为什么......
有什么建议么?
解决方案
当您在刀片模板中使用 @include 时,它会在resource/views
目录中查找文件。所以像这样使用它@include('posts/index')
。
它将在views/posts/
目录中查找 index.php。
不要在@include 中使用.php。
@extends('template')
@section('contenu')
<div id="app">
@include("yourDirectory/oldfile");
</div>
@endsection
推荐阅读
- java - 在 C/C++ 中使用布尔数组参数调用 JAVA 的布尔数组方法
- python - 如何在python中隐藏导入行?
- reactjs - Reactjs Leaflet 自定义控制按钮
- python - 如何合并两个在不同数据流上训练的 CNN?
- ruby-on-rails - 如何从 Redis INFO 获取特定值
- python - Apache AIRFLOW - 如何将参数发送到 Python 脚本
- crystal-lang - 为什么在信号陷阱块中杀死的进程会变成僵尸而不是定期终止?
- java - 无法通过限定符注入
- java - 在webdriver java中将凭证循环为数组
- c# - IActivityLogger 不记录 PromptDialog.Choice 文本