如何将PHP与组成API VUEJS 3使用

发布于 2025-01-31 13:49:54 字数 416 浏览 0 评论 0原文

来自PHP/jQuery背景,您可以在同一文件中使用PHP和jQuery代码,例如某些名为index.php的文件:

<?php
echo "hey";
?>

<script>
$("#someId").html("abc")
</script>

如何使用vuejs v3 您可以在其中访问.vue文件内的访问PHP变量/会话等。或者您的SFC文件也包括PHP代码?

我知道您可以通过在index.php文件中加入脚本标签的VUE框架来做到这一点,但据我所知,您无法使用此方法使用构图API。

我可能缺少一些基本的东西,但我找不到答案。

Coming from a PHP/jQuery background, where you can have PHP and jQuery code in the same file, for example some file called index.php:

<?php
echo "hey";
?>

<script>
$("#someId").html("abc")
</script>

How can you do something similar with the Composition API in VueJS v3 where you can access access your PHP variables/sessions etc. inside of a .vue file or have your SFC files to include PHP code as well?

I know you can do this by including the vue framework with script tags inside of your index.php file but as far as I'm aware you can't use the Composition API with this method.

I'm probably missing something basic but I haven't been able to find the answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文