gpt4 book ai didi

php - fatal error : Call to undefined function asset() in C:\wamp\www\laravel-master\app\views\hello. PHP

转载 作者:可可西里 更新时间:2023-11-01 01:00:11 30 4
gpt4 key购买 nike

我想学习 laravel 框架。我可以在我的网络服务器(Wamp)中安装 laravel,我得到了一些学习它的教程,但是当我尝试将样式添加到 hello.php 文件中的“h1”标签时,位于该路径中:(“C:\wamp\www\laravel-master\app\views\hello.php") 通过asset()函数,出现上述错误。请帮我找出问题所在。这是 hello.php 代码:

        <style>

body {
margin:0;
font-family:'Lato', sans-serif;
text-align:center;
color: #999;
}

.welcome {
width: 300px;
height: 200px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -150px;
margin-top: -100px;
}

a, a:visited {
text-decoration:none;
}

h1 {
font-size: 32px;
margin: 16px 0 0 0;
}
</style>
</head>
<link rel="stylesheet" type="text/css" href="<?php echo asset('css/main.css'); ?>" >
<body>
<div class="welcome">
<a href="http://laravel.com" title="Laravel PHP Framework"> <img src="some_long_src" alt="Laravel PHP Framework"></a>
<h1 class="highlight">You have arrived.</h1>
</div>
</body>
</html>

和 main.css :

.highlight {
border: solid 2px #F00;
}

我的 laravel 版本是 4.2.16。

提前致谢。

最佳答案

我正在使用 Laravel 5.2 版

我用这个没问题:

  <!-- JavaScripts -->
<script src="{{ asset('js/main.js') }}"></script>

关于php - fatal error : Call to undefined function asset() in C:\wamp\www\laravel-master\app\views\hello. PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29716694/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com