简体   繁体   English

为什么gulp和浏览器同步路径不正确

[英]Why the path is incorrect with gulp and browser-sync

This is my code with gulp and browser-sync 这是我用gulp和浏览器同步的代码 在此处输入图片说明

Now, why the error of this path: 现在,为什么会出现此路径错误: 在此处输入图片说明

the current directory structure is this: 当前目录结构是这样的:

在此处输入图片说明

and the css style: 和CSS样式:

在此处输入图片说明

Your style is in the tmp/styles folder. 您的样式在tmp/styles文件夹中。 When your css url is set to ./images/landing.jpg , that single dot simply means to look in the current folder. 当您将CSS网址设置为./images/landing.jpg ,该单个点仅意味着在当前文件夹中查找。 So BrowserSync does exactly what you ask and looks for an images folder inside of the styles folder. 因此,BrowserSync完全按照您的要求进行操作,并在styles文件夹内查找images文件夹。 So, it's your CSS that is wrong, not BrowserSync. 因此,错误的是CSS,而不是BrowserSync。

What you actually want is to back out to the parent directory of the styles folder, and look for an images folder there, which is accomplished with two periods: 您真正想要的是退回到styles文件夹的父目录,并在其中查找images文件夹,这需要两个周期才能完成:

background: url("../images/landing.jpg") no-repeat center;

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

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