zoukankan      html  css  js  c++  java
  • VUE CLI中使用Jquery无法获取到dom节点

    mounted

    • 类型:Function

    • 详细:

      实例被挂载后调用,这时 el 被新创建的 vm.$el 替换了。如果根实例挂载到了一个文档内的元素上,当 mounted 被调用时 vm.$el 也在文档内。

      注意 mounted 不会保证所有的子组件也都被挂载完成。如果你希望等到整个视图都渲染完毕再执行某些操作,可以在 mounted 内部使用 vm.$nextTick

      mounted: function () {
        this.$nextTick(function () {
          // 仅在整个视图都被渲染之后才会运行的代码
        })
      }

      该钩子在服务器端渲染期间不被调用。

    <template>
      <div class="app-container">
        <div style="background-color: antiquewhite; height: 100px;  200px">
          <span id="spTest">sdfsdf</span>
          <div id="slider"></div>
        </div>
      </div>
    </template>
    <style>
    @import "/Content/JS/Jquery/jqueryui.min.css";
    @import "/Content/JS/Jquery/jquery-ui-slider-pips.min.css";
    </style>
    <script>
    export default {
      name: "imgview/viewimg2",
      created() {
        that.$nextTick(function () {
          debugger;
        });
      },
      mounted() {
        this.$nextTick(function () {
          console.log("log:");
          console.log($("#spTest").html());
          $("#slider").slider();
        });
      },
    };
    
    // $("#myslider").slider().slider("pips").slider("float");
    </script>
    

      

  • 相关阅读:
    软工实践4
    软工实践3
    软工实践1
    《暗时间》读书笔记
    关系规范化(数据库)
    关于Git的初步使用
    软件体系结构模式
    第六周编程总结
    第五周编程总结
    第四周编程总结
  • 原文地址:https://www.cnblogs.com/MarsPanda/p/15767460.html
Copyright © 2011-2022 走看看