简体   繁体   English

提供lesscss样式表

[英]Serving lesscss stylesheets

I am trying to link to a LESS stylesheet with Django. 我正在尝试使用Django链接到LESS样式表。 The file is stored in my static folder and all of the javascript and css files are served without a problem. 该文件存储在我的静态文件夹中,并且所有的javascript和css文件都可以正常使用。

When I use a '.less' extension on my file, I get the following error: 当我在文件上使用'.less'扩展名时,出现以下错误:

XMLHttpRequest cannot load...
Origin null is not allowed by Access-Control-Allow-Origin.

When I visit the page directly, a download prompt pops up for the file. 当我直接访问该页面时, 将弹出下载提示提示该文件。

When I take the extension off completely, I get a black screen in my web browser and can't bring up the console in Chrome. 完全关闭扩展程序后,我的网络浏览器出现黑屏,并且无法启动Chrome中的控制台。

When I use the '.txt' extension I can view the page fine, but still get the same error above when I try to link to it. 当我使用'.txt'扩展名时,我可以很好地查看该页面,但是当我尝试链接到该页面时,仍然会收到与上面相同的错误。

<link rel="stylesheet/less" type="text/css" href="static/CSS/BaseLess.txt">
<script src="/Plugins/less-1.3.0.js" type="static/text/javascript"></script>

Any ideas how I can solve this? 有什么想法可以解决这个问题吗? Let me know if you want to see more Less code or error message. 如果您想查看更多更少的代码或错误消息,请告诉我。

Edit I was actually serving my less files from a different server and You cannot access data from another server with an XMLHttpRequest . 编辑实际上,我实际上是从其他服务器提供较少的文件,并且您不能使用XMLHttpRequest从其他服务器访问数据

I switched the file over to the same server and it worked fine with the less extension. 我将文件切换到同一台服务器,但扩展名较少的情况下工作正常。

Edit I was actually serving my less files from a different server and You cannot access data from another server with an XMLHttpRequest. 编辑实际上,我实际上是从其他服务器提供较少的文件,并且您无法使用XMLHttpRequest从另一台服务器访问数据。

I switched the file over to the same server and it worked fine with the less extension. 我将文件切换到同一台服务器,但扩展名较少的情况下工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM