为本地开发环境编写脚本 'src' url 的正确方法是什么?

2022-01-25 00:00:00 localhost javascript src

我正在本地环境中工作,我不确定我是否正确编写了我的 src URl,因为我的功能无法正常工作.粗体脚本标签包含有问题的 src.

I'm working on a local environment and I'm not sure if I've written my src URl correctly because my functions aren't working. The bold script tag has the src in question.

<!DOCTYPE html>
<html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script src="http://www.parsecdn.com/js/parse-1.2.2.min.js"></script>

    **<script src="/Users/myUserName/Desktop/myPage.js"></script>**

    </head>
    <body>
        <div id="mainDiv">
            <p><a href="#">anchor</a></p>
        </div>
    </body>
</html>

推荐答案

将调用js文件的src标签写为

Write the src tag for calling the js file as

<script type='text/javascript' src='../Users/myUserName/Desktop/myPage.js'></script>

这应该可行.

相关文章