我正在努力学习VueJS和Twig。我制作了自己的MVC (只是为了好玩),它工作得很好,问题在于不能包含JS或CSS文件。
当我按下CTRL+U并查看我的源码时,我点击我的javascript文件,然后页面用正确的网址重新加载,但我仍然可以看到我的索引页面……
我不知道是什么导致了这个问题,也不知道-or如何解决这个问题。有没有人有办法解决这个问题?
root htaccess公共htaccess
我的根htaccess文件是:
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>而我的公用文件夹中的htaccess文件是
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /public
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>我的布局(索引)页面是这样的:
<!DOCTYPE html>
<html>
<head>
<title>Beta</title>
<link rel="stylesheet" href="../../public/css/style.css" />
<script src="../../node_modules/vue/dist/vue.min.js"></script>
<script src="../../public/js/scripts.js"></script>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>如上所述,当我点击我的CSS或JS文件时,我在源代码中看到以下内容:
<!DOCTYPE html>
<html>
<head>
<title>Beta</title>
<link rel="stylesheet" href="../../public/css/style.css" />
<script src="../../node_modules/vue/dist/vue.min.js"></script>
<script src="../../public/js/scripts.js"></script>
</head>
<body>
Hello there!
</body>
</html>希望有人能帮帮我!
更新:我将我的htaccess更改为:
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?/$1 [L,NC]
</IfModule>现在我的CSS和JS是可见的,但是node_modules (Vue)仍然只显示索引页面的源代码这种奇怪的行为。
发布于 2019-01-25 15:27:18
显然是菜鸟犯的错误!
您不能包含"node_modules“文件夹中的内容。我使用GULP将所有内容包含并编译到我的一个可公开访问的文件夹中,现在我可以很好地包含它们!
https://stackoverflow.com/questions/54356213
复制相似问题