polymer - 将 Polymer 应用程序提供给不在根目录下的/path

标签 polymer

所以我想对一个新的 Polymer 应用程序做的第一件事是部署到现有网站上的目录。唯一似乎有效的是部署到 root / .

让我们以 Shop 为例。我愿意:

  • polymer init并选择店铺
  • polymer build
  • Robocopy.exe .\build\bundled\ C:\inetpub\wwwroot\p\ /MIR
  • start http://localhost/p/

  • 你看我在 Windows 上。我认为使用 IIS 无关紧要,因为我依赖服务器只是为了提供静态内容。

    我需要在商店模板中编辑什么才能使其在 url http://localhost/p/ 上工作?

    最佳答案

    polymer cli 创建的应用程序假设从根级别“/”提供服务。在生成的项目中 index.html你会发现两条评论

    <!--
    
          The `<base>` tag below is present to support two advanced deployment options:
          1) Differential serving. 2) Serving from a non-root path.
        
          Instead of manually editing the `<base>` tag yourself, you should generally either:
          a) Add a `basePath` property to the build configuration in your `polymer.json`.
          b) Use the `--base-path` command-line option for `polymer build`.
        
          Note: If you intend to serve from a non-root path, see [polymer-root-path] below.
    
    -->
        <base href="/">
    <!-- ... -->
    
    <script>
        /**
        * [polymer-root-path]
        *
        * By default, we set `Polymer.rootPath` to the server root path (`/`).
        * Leave this line unchanged if you intend to serve your app from the root
        * path (e.g., with URLs like `my.domain/` and `my.domain/view1`).
        *
        * If you intend to serve your app from a non-root path (e.g., with URLs
        * like `my.domain/my-app/` and `my.domain/my-app/view1`), edit this line
        * to indicate the path from which you'll be serving, including leading
        * and trailing slashes (e.g., `/my-app/`).
        */
        window.Polymer = {rootPath: '/'};
      // ...    
     
    
    </script>


    如果在此 index.html您注释掉的文件 base标记并设置 window.Polymer rootPath类似于 '/0/polymer-test/build/es5-bundled/'您将能够在 http://localhost/0/polymer-test/build/es5-bundled/ 上的应用程序中导航

    关于polymer - 将 Polymer 应用程序提供给不在根目录下的/path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42090070/

    相关文章:

    polymer - 两个 polymer 元素之间的数据绑定(bind)

    Polymer,如何将值传递给需要字符串的 paper-date-picker 属性?

    javascript - 如何在 polymer 中使用 jQuery 动态更改数组?

    java - 如何解析 JSDoc

    polymer - 如何在 polymer 模板中转义大括号 {{var}}?

    javascript - polymer :来自另一个元素的实例 polymer 元素

    arrays - 数组长度错误,Polymer 中 dom-repeat 上有空行

    javascript - 在 Polymer 中通过 JS 更改 CSS 变量

    reactjs - 如何在 polymer 组件内部使用 React?

    javascript - 将具有数据绑定(bind)的 "dynamic"元素添加到我的 polymer 元素