Why file after webpack package should be placed on the server to run?

Why is there this Question:

  At the beginning of the use of vue-cli do not know the file you want to run the service pack, the point directly after the opening page found whiteboards, after big ask God that chooses a service to run up my mind at that time the logic is Such:

    Because : js code that is interpreted by the browser running, web server code that can be compiled nodejs

    And because : used in the project only js and nodejs, nodejs to run in the service

    So : In the webpack file is packaged in a nodejs

  Today my mind suddenly flashed thought of this issue, specifically to see the file after packing, after a search after the discovery, file package, he did not meow nodejs, ignorant force ~~~

solve:

  The first step simply double-click to open the html packaged locally, we found:

      

      Mainly: 1. Direct points after taking the open file protocols; 2 all the resources did not load handling;.

      Js preliminary judgment is not because the page is loaded out of the whiteboard caused by open index.html:

      

      Mainly: 1. red box where there should be no quotation marks and codes; 2 blue arrow begins with /, and in the beginning of the file protocol / representatives root, these paths will be resolved as absolute. path

      Corrections, too:

      

      Double-click the html file to run:

      

 

       Normal, and there is no error.

to sum up:

    Actually http protocol and html file protocol for different resource paths analytical methods.

        

Reproduced in: https: //www.cnblogs.com/alongWind/p/7516148.html

                        <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count"></span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/b1373876996">
                    <img src="https://profile.csdnimg.cn/C/6/3/3_b1373876996" class="avatar_pic" username="b1373876996">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/1x/3.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/b1373876996" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">b1373876996</a></span>
                                            </div>
                    <div class="text"><span>发布了0 篇原创文章</span> · <span>获赞 0</span> · <span>访问量 193</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://im.csdn.net/im/main.html?userName=b1373876996" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                        </a>
                                                            <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                    </div>
                            </div>
                    </div>
    
Published 10 original articles · won praise 0 · Views 324

Why is there this Question:

  At the beginning of the use of vue-cli do not know the file you want to run the service pack, the point directly after the opening page found whiteboards, after big ask God that chooses a service to run up my mind at that time the logic is Such:

    Because : js code that is interpreted by the browser running, web server code that can be compiled nodejs

    And because : used in the project only js and nodejs, nodejs to run in the service

    So : In the webpack file is packaged in a nodejs

  Today my mind suddenly flashed thought of this issue, specifically to see the file after packing, after a search after the discovery, file package, he did not meow nodejs, ignorant force ~~~

solve:

  The first step simply double-click to open the html packaged locally, we found:

      

      Mainly: 1. Direct points after taking the open file protocols; 2 all the resources did not load handling;.

      Js preliminary judgment is not because the page is loaded out of the whiteboard caused by open index.html:

      

      Mainly: 1. red box where there should be no quotation marks and codes; 2 blue arrow begins with /, and in the beginning of the file protocol / representatives root, these paths will be resolved as absolute. path

      Corrections, too:

      

      Double-click the html file to run:

      

 

       Normal, and there is no error.

to sum up:

    Actually http protocol and html file protocol for different resource paths analytical methods.

        

Reproduced in: https: //www.cnblogs.com/alongWind/p/7516148.html

                        <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#csdnc-thumbsup"></use>
                        </svg><span class="name">点赞</span>
                        <span class="count"></span>
                        </a></li>
                        <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-Collection-G"></use>
                        </svg><span class="name">收藏</span></a></li>
                        <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                            <use xlink:href="#icon-csdnc-fenxiang"></use>
                        </svg>分享</a></li>
                        <!--打赏开始-->
                                                <!--打赏结束-->
                                                <li class="tool-item tool-more">
                            <a>
                            <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                            </a>
                            <ul class="more-box">
                                <li class="item"><a class="article-report">文章举报</a></li>
                            </ul>
                        </li>
                                            </ul>
                </div>
                            </div>
            <div class="person-messagebox">
                <div class="left-message"><a href="https://blog.csdn.net/b1373876996">
                    <img src="https://profile.csdnimg.cn/C/6/3/3_b1373876996" class="avatar_pic" username="b1373876996">
                                            <img src="https://g.csdnimg.cn/static/user-reg-year/1x/3.png" class="user-years">
                                    </a></div>
                <div class="middle-message">
                                        <div class="title"><span class="tit"><a href="https://blog.csdn.net/b1373876996" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">b1373876996</a></span>
                                            </div>
                    <div class="text"><span>发布了0 篇原创文章</span> · <span>获赞 0</span> · <span>访问量 193</span></div>
                </div>
                                <div class="right-message">
                                            <a href="https://im.csdn.net/im/main.html?userName=b1373876996" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                        </a>
                                                            <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                    </div>
                            </div>
                    </div>
    

Guess you like

Origin blog.csdn.net/qq_30627241/article/details/103784295