简体   繁体   中英

what is difference between '../js/vue' and 'test/data/js/vue.js'?

I'm not sure about this error. I use require.js to require file in js folder , like this:

require(['../js/vue'],function(){});

But i add baseUrl , it have error

require([baseUrl+'/js/vue'],function(){});

it is similar to

require(['test/data/js/vue'],function(){});
//Failed to load resource: the server responded with a status of 404 (Not Found)
//Uncaught Error: Script error for

If i add extension .js:

require(['test/data/js/vue.js'], function(){}); //It work fine

what is difference between '../js/vue' and 'test/data/js/vue.js'?

the .. stands for one directory up. Let's say you created a src folder and within the source folder you have 3 folders, html, css, js. For example when you want to go from your html directory to your js dir. You can do that by typing ../js/FILE.js but you could also do /src/js/FILE.js . But there is something called path traversal exploits which can be caused by going up directories with ../ , so for that reason, I recommend you to just never use ../ . And aside from having security issues, in my opinion it is way easier to read the full directory with parent directories then just the ../ .

So in short the difference is that with the .. you first go up one directory and then down to where you want to go. Without the .. you only go down in the file system. That makes it safer to use than using the .. .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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