• <bdo id='u7unP'></bdo><ul id='u7unP'></ul>

      1. <legend id='u7unP'><style id='u7unP'><dir id='u7unP'><q id='u7unP'></q></dir></style></legend>

        <small id='u7unP'></small><noframes id='u7unP'>

      2. <tfoot id='u7unP'></tfoot>

      3. <i id='u7unP'><tr id='u7unP'><dt id='u7unP'><q id='u7unP'><span id='u7unP'><b id='u7unP'><form id='u7unP'><ins id='u7unP'></ins><ul id='u7unP'></ul><sub id='u7unP'></sub></form><legend id='u7unP'></legend><bdo id='u7unP'><pre id='u7unP'><center id='u7unP'></center></pre></bdo></b><th id='u7unP'></th></span></q></dt></tr></i><div id='u7unP'><tfoot id='u7unP'></tfoot><dl id='u7unP'><fieldset id='u7unP'></fieldset></dl></div>
      4. 尽管在静态目录中有它,但无法将 javascript 应用于我在烧瓶中的模板.如何在下面的代码中解决这个问题?

        Couldn#39;t apply javascript to my template in flask despite having it in the static dir. How do I resolve that in the code below?(尽管在静态目录中有它,但无法将 javascript 应用于我在烧瓶中的模板.如何在下面的代码中解决这个问题?) - IT屋-程序
        <i id='zC3KW'><tr id='zC3KW'><dt id='zC3KW'><q id='zC3KW'><span id='zC3KW'><b id='zC3KW'><form id='zC3KW'><ins id='zC3KW'></ins><ul id='zC3KW'></ul><sub id='zC3KW'></sub></form><legend id='zC3KW'></legend><bdo id='zC3KW'><pre id='zC3KW'><center id='zC3KW'></center></pre></bdo></b><th id='zC3KW'></th></span></q></dt></tr></i><div id='zC3KW'><tfoot id='zC3KW'></tfoot><dl id='zC3KW'><fieldset id='zC3KW'></fieldset></dl></div>
      5. <legend id='zC3KW'><style id='zC3KW'><dir id='zC3KW'><q id='zC3KW'></q></dir></style></legend>

            <bdo id='zC3KW'></bdo><ul id='zC3KW'></ul>
                <tfoot id='zC3KW'></tfoot>

                  <tbody id='zC3KW'></tbody>

                  <small id='zC3KW'></small><noframes id='zC3KW'>

                  本文介绍了尽管在静态目录中有它,但无法将 javascript 应用于我在烧瓶中的模板.如何在下面的代码中解决这个问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个烧瓶项目,我正在尝试制作 tree 结构,但我不认为 JS 被应用于我的 tree.html它无法扩展选项.以下是我在互联网上找到的代码,由于我没有任何前端经验,因此我正在尝试使其工作.非常感谢您的帮助.

                  I have a flask project in which I'm trying to make a tree structure but I don't think the JS is being applied to my tree.html as it couldn't expand the options. Below is the code that I found in internet which I'm trying to make work as I don't have any frontend experience. I'd be grateful for your help.

                  Base.html

                  <!DOCTYPE html>
                  <html lang="en">
                  <head>
                      <meta charset="UTF-8">
                      <title>{% block title %}{% endblock %}</title>
                      <script type="text/javascript" src="/static/jsfun.js"></script>
                  </head>
                  <body>
                  {% block content %}
                  {% endblock %}
                  </body>
                  </html>
                  

                  tree.html

                  {% extends "base.html" %}
                  
                  {% block content %}
                      <ul class="tree">
                          <li><a href="#">Part 1</a>
                              <ul>
                                  <li><a href="#">Item A</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item B</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item C</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item D</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item E</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                              </ul>
                          </li>
                  
                          <li><a href="#">Part 2</a>
                              <ul>
                                  <li><a href="#">Item A</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item B</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item C</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item D</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item E</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                              </ul>
                          </li>
                  
                          <li><a href="#">Part 3</a>
                              <ul>
                                  <li><a href="#">Item A</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item B</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item C</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item D</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                                  <li><a href="#">Item E</a>
                                      <ul>
                                          <li><a href="#">Sub-item 1</a></li>
                                          <li><a href="#">Sub-item 2</a></li>
                                          <li><a href="#">Sub-item 3</a></li>
                                      </ul>
                                  </li>
                              </ul>
                          </li>
                      </ul>
                  {% endblock %}
                  

                  jsfun.js

                  var tree = document.querySelectorAll('ul.tree a:not(:last-child)');
                  for(var i = 0; i < tree.length; i++){
                      tree[i].addEventListener('click', function(e) {
                          var parent = e.target.parentElement;
                          var classList = parent.classList;
                          if(classList.contains("open")) {
                              classList.remove('open');
                              var opensubs = parent.querySelectorAll(':scope .open');
                              for(var i = 0; i < opensubs.length; i++){
                                  opensubs[i].classList.remove('open');
                              }
                          } else {
                              classList.add('open');
                          }
                      });
                  }
                  

                  这是页面打开的时间

                  当我点击任何项目时,什么都没有发生:

                  And nothing happens when I click any item:

                  推荐答案

                  请查看 this repo.检查你在哪里犯了错误.我相信它是您导入 js 文件的方式.你应该像下面这样使用

                  Please check this repo. Check where you are making a mistake. I believe its the way you are importing the js file. you should use like below

                  <script src="{{ url_for('static', filename='js/jsfun.js') }}"></script>
                  

                  这篇关于尽管在静态目录中有它,但无法将 javascript 应用于我在烧瓶中的模板.如何在下面的代码中解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  Embed YouTube video - Refused to display in a frame because it set #39;X-Frame-Options#39; to #39;SAMEORIGIN#39;(嵌入 YouTube 视频 - 拒绝显示在框架中,因为它将“X-Frame-Options设置为“SAMEORIGIN)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                • <i id='6db09'><tr id='6db09'><dt id='6db09'><q id='6db09'><span id='6db09'><b id='6db09'><form id='6db09'><ins id='6db09'></ins><ul id='6db09'></ul><sub id='6db09'></sub></form><legend id='6db09'></legend><bdo id='6db09'><pre id='6db09'><center id='6db09'></center></pre></bdo></b><th id='6db09'></th></span></q></dt></tr></i><div id='6db09'><tfoot id='6db09'></tfoot><dl id='6db09'><fieldset id='6db09'></fieldset></dl></div>

                      <small id='6db09'></small><noframes id='6db09'>

                      <tfoot id='6db09'></tfoot>
                        <bdo id='6db09'></bdo><ul id='6db09'></ul>
                          <tbody id='6db09'></tbody>

                          • <legend id='6db09'><style id='6db09'><dir id='6db09'><q id='6db09'></q></dir></style></legend>