【问题标题】:Undefined variable AMP and laravel未定义的变量 AMP 和 laravel
【发布时间】:2018-01-08 10:22:50
【问题描述】:

如何使用 laravel 和 AMP 从服务器呈现错误/成功消息,这里是一个示例,但它不起作用我得到未定义的变量

服务器端(laravel)

public function userAjaxHasNotLogedIn()
{
    return response()->json(['loged' => false], 400)
                     ->header('AMP-Access-Control-Allow-Source-Origin',"http://localhost:8000");
}

函数工作正常,它返回一个带有变量 loged 的​​ json 文件

客户端 (AMP)

<div submit-error>
  <template type="amp-mustache">
    <a style="cursor: pointer;" id="submitloginbtn" on="tap:loginform.show,submitloginbtn.hide" > Réessayer </a>
  </template>
</div><div submit-success>
<template type="amp-mustache">Vous êtes connecté {{ loged }}</template></div>

错误使用未定义的常量已记录 - 假定为“已记录”

【问题讨论】:

  • 在查询中添加json数据会更好。
  • 没看懂,请解释一下

标签: laravel amp-html


【解决方案1】:

您似乎正在尝试将刀片语法与 javaScript 一起使用。你可以这样做。使用 @ 和刀片 @{{logged}}

<div submit-error>
<template type="amp-mustache">
<a style="cursor: pointer;" id="submitloginbtn" on="tap:loginform.show,submitloginbtn.hide" > Réessayer </a>

Vous êtes connecté @{{ 登录 }}

【讨论】:

  • 你能告诉我在文档中哪里可以找到它
猜你喜欢
  • 1970-01-01
  • 2019-04-29
  • 1970-01-01
  • 2015-05-15
  • 2019-03-01
  • 2023-03-05
  • 2018-01-26
  • 2020-09-24
  • 2021-10-31
相关资源
最近更新 更多