phoenix中的web/static和priv/static有什么区别? [英] What is the different between web/static and priv/static in phoenix?
问题描述
我是不老长寿药和凤凰药的新手.现在我在凤凰城的静态资产上遇到了麻烦.
I am new to elixir and phoenix. Now I have trouble with the static assets in phoenix.
我想在页面中添加一个js文件,然后在模板中添加以下代码:
I want to add a js file in my page, and I add the following code in my template:
<script src="<%= static_path(@conn, "/js/test.js") %>"></script>
,然后在web/static/js/test.js
处创建一个js文件.
and then create a js file at web/static/js/test.js
.
但是,在浏览器的控制台中找不到关于test.js
的错误.
However, I got the error about test.js
is not found in the browser's console.
我注意到有一个priv/static/js
文件夹,我尝试在priv/static/js/test.js
上创建js文件.
I notice there is a priv/static/js
folder, and I try to create the js file at priv/static/js/test.js
.
这次,错误消失了.
我对此感到非常困惑.
I am really confuse about this.
web/static
和priv/static
有什么区别?如果需要在开发环境中测试静态文件,应该将静态文件放在哪里?
以及生产环境如何?
What is the different between web/static
and priv/static
? If I need to test my static files in develop environment, where should I put the static files?
and how about the production environment ?
谢谢.
推荐答案
Priv/static包含已处理和串联的文件.即,它们将在编译后保存在此文件夹中.但是,请检查您的早午餐是否可以正常工作,因为它会从Web/static中获取文件.为了更好的理解,我建议您仔细阅读文档 http://www.phoenixframework.org/docs/static-assets
Priv/static contains processed and concatenated files. I.e they will be saved in this folder after the compilation. However check if your Brunch is working as it takes files from web/static. For better understanding i recommend you go through the doc http://www.phoenixframework.org/docs/static-assets
这篇关于phoenix中的web/static和priv/static有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!