【问题标题】:My Page.ss wont load css and script SilverStripe v4.2.1我的 Page.ss 不会加载 css 和脚本 SilverStripe v4.2.1
【发布时间】:2018-10-29 13:10:35
【问题描述】:

我有 WAMP 作为我的本地服务器。我仔细按照说明进行操作,但无法在 Page.ss 上加载我的 css 和脚本。我刷新了缓存并刷新了页面并更新了 href,但它们似乎都没有工作。

Page.ss

<html>
<head>
<title></title>
<meta charset = "UTF-8">
<meta name="description" content= "">
<meta name="author" content= "Lisandro">
<meta name="keywords" content= "">
<meta name="viewport" content="width=device-width" initial-scale="1">
<link rel="stylesheet" 
href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">

<link href="https://fonts.googleapis.com/css?family=Noto+Sans" 
rel="stylesheet">
<link rel="stylesheet" type="text/css" href="themes/u-mart/css/slick.css">
<link rel="stylesheet" type="text/css" href="themes/u-mart/css/slick- 
theme.css">       
<link rel="stylesheet" type="text/css" href="themes/u-mart/css/style.css">
<link rel="stylesheet" 
 href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">

<script src="https://code.jquery.com/jquery-3.3.1.js"></script>


</head>
<body>
"TONS OF HTML CODES"
</body>
</html>

【问题讨论】:

    标签: html css silverstripe silverstripe-4


    【解决方案1】:

    找到了答案。您所要做的就是在您的 .SS 文件中添加这些行。

     <% require css("<my-module-dir>/css/some_file.css") %>
     <% require themedCSS("some_themed_file") %>
     <% require javascript("<my-module-dir>/javascript/some_file.js") %>
    

    他们网站的课程和视频中都没有提到这些。您将不得不自己挖掘。

    【讨论】:

    • 不错!您需要这样做的原因是,需求 API 将解析存在于 public/ 子文件夹(以及 resources/)中的引用,而 themes/ 文件夹不能通过 Web 服务器直接访问。您应该接受您的答案作为正确的解决方案,甚至可以提出拉取请求以澄清未来的课程 - 它都是开源的! github.com/silverstripe/silverstripe-lessons-v4
    猜你喜欢
    • 1970-01-01
    • 2021-08-11
    • 2018-02-09
    • 2018-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-08
    相关资源
    最近更新 更多