laravel - 尝试将 chart.js 与 Laravel-charts 包一起使用时 Laravel Vue 错误
问题描述
我正在使用来自https://charts.erik.cat/的 Laravel 图表,我注意到我收到了以下错误。
我还注意到,当我删除此行时错误消失了(与我在生成内容之前放置在布局中的渲染有关):但是当我这样做时,图表不起作用。
{!! $chart->script() !!}
在我放置的内容中:
{!! $chart->container() !!}
我猜app.js有一些冲突吗?
app.js:38309 [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 <script>, as they will not be parsed.
191|
192| </main>
193| <script type="text/javascript">
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
194| var ctvChart = document.getElementById('mzaqnvhkcsrjgeoxdwuipybtl').getContext('2d');
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195| function mzaqnvhkcsrjgeoxdwuipybtl_create(data) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196| mzaqnvhkcsrjgeoxdwuipybtl_rendered = true;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
197| document.getElementById("mzaqnvhkcsrjgeoxdwuipybtl_loader").style.display = 'none';
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198| document.getElementById("mzaqnvhkcsrjgeoxdwuipybtl").style.display = 'block';
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
199| window.mzaqnvhkcsrjgeoxdwuipybtl = new Chart(document.getElementById("mzaqnvhkcsrjgeoxdwuipybtl").getContext("2d"), {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
.(...there is more)
解决方案
我通过移动来修复它
{!! $chart->script() !!}
在布局中的标签之外。我不确定为什么,但它不再显示该警告。
推荐阅读
- wordpress - 如何将参数发送到另一个页面上的 iframe?
- python - 使用 groupby 作为用户 ID 并组合字符串
- php - 如何将连接的 MYSQL 字符串查询存储到 PHP 变量中?
- python - 如何将整数位掩码解码为原始输入字符
- elasticsearch - 某些弹性字段 DSL 查询可搜索,有些则不可搜索
- java - 使用 List 或 Arraylist 的字符串字母顺序
- javascript - 模块不提供名为“default”的导出
- spring-boot - @EnableWebSecurity 和 #oauth2.clientHasRole - 为什么它不起作用?
- spring - 在运行三足事务时避免死锁
- php - 新的 MongoDB\BSON\Regex 搜索带有撇号或括号的文本