Coder Social home page Coder Social logo

public-component's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

public-component's Issues

水印组件有bug

  1. 生命周期函数的destroy应该为destroyed。
  2. 假设有A, B两个页面,只需要在A页面添加水印,B页面不需要,则需在A页面中引入水印组件waterMark, 并把inputDestroy为true时,这时候就会出现一个bug,复现如下:进入页面A,看到水印,然后打开开发者工具,手动删除生成的水印节点,然后跳转到页面B,这时候页面B也会显示水印,究其原因是从页面A跳转到B页面的时候,水印组件销毁,执行removeMaskDiv()函数删除了添加在body下面的水印节点,因为节点发生了改变,这又导致了callback函数的执行。
    image,因此body下面又生成了水印节点。所以在页面B还是能看到水印。
    解决方法是将observer挂到组件上,
this.observer = new MutationObserver(this.callback);
this.observer.observe(body, options); 

destroyed生命周期函数里面:

 destroyed() {
   if (this.inputDestroy) {
     // 添加这一句
      this.observer.disconnect();
      this.removeMaskDiv();
    }
  },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.