我正在使用带有github代码空间的Laravel Framework 10.1.5
进行编码。
我使用php artisan serve
启动服务器,当我想在我的刀片视图中加载css-file
时,我使用<link href="{{ asset('fonts/google-font/css.css') }}" rel="stylesheet">
。
但是,此链接解析为:<link href="http://localhost/fonts/google-font/css.css" rel="stylesheet">
我的代码空间URL看起来像这样:https://githubUser-legendary-goggles-vp4432qvj12xsas32y234-8000.preview.app.github.dev/
因此,我的css文件没有加载。
我使用的是devcontainer
,下面是我的配置:
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "codespaces-laravel",
"dockerComposeFile": ["docker-compose.yml"],
"workspaceFolder": "/workspace",
"service": "app",
"shutdownAction": "stopCompose",
"extensions": [
"editorconfig.editorconfig",
"ryannaddy.laravel-artisan",
"amiralizadeh9480.laravel-extra-intellisense",
"stef-k.laravel-goto-controller",
"codingyu.laravel-goto-view",
"mikestead.dotenv",
"eg2.tslint",
"christian-kohler.path-intellisense",
"esbenp.prettier-vscode",
"CoenraadS.bracket-pair-colorizer"
],
"settings": {
"#terminal.integrated.shell.linux": "/bin/bash"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [80],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "cp .env.example .env && composer install && php artisan key:generate && yarn install && yarn run development",
"portsAttributes": {
"80": {
"label": "HTTP"
}
}
}
有什么建议吗
1条答案
按热度按时间z2acfund1#
资源辅助对象预先添加在.env文件中定义的
ASSET_URL
。您可以更新您的
ASSET_URL
以指向您的.env文件中的网站URLhttps://githubUser-legendary-goggles-vp4432qvj12xsas32y234-8000.preview.app.github.dev/
。https://laravel.com/docs/10.x/helpers#method-asset