由于magento2对windows的兼容性并不好,win10系统在安装Magento2完成页面空白,F2查看js查看报错,或者报如下错误:
Invalid template file: '***/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml' in module: '' block's name: 'require.js'
打开var/log/system.log查看错误日志如下:
项目根目录找到文件:vendor/magento/framework/View/Element/Template/File/Validator.php
在139行的位置找到:
foreach ($directories as $directory) {
if (0 === strpos($realPath, $directory)) {
return true;
}
}
替换为:
foreach ($directories as $directory) {
$realDirectory = $this->fileDriver->getRealPath($directory);
if (0 === strpos($realPath, $realDirectory)) {
return true;
}
}
重新编译一遍
php bin/magento setup:static-content:deploy -f
完成!