You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel Vite构建后@vite指令触发数组转字符串转换错误

问题解决:构建后出现Array to string conversion错误

错误原因

你在Blade模板中使用@vite指令时,传入了两个独立的数组参数,这不符合该指令的语法要求。@vite只接受一个包含所有资源路径的数组,生产构建时会因参数格式错误触发数组转字符串的异常,而开发环境的热重载机制可能暂时掩盖了这个问题。

修复方法

把两个数组合并成一个数组传入@vite:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    @vite(['resources/scss/app.scss', 'resources/js/app.js'])
</head>
<body>
</body>
</html>

验证步骤

  • 执行npm run build重新构建生产资源
  • 预览页面,确认错误消失

内容的提问来源于stack exchange,提问作者May

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 00:43:16