iframe通信

1.iframe通信

// IFrame
      window.addEventListener('message', event => {
        const message = event.data;        
        if (message.type === 'mess') {
          console.log(message.path)
        }
        // if (message.data === 'Hello IFrame!') {
        //   const response = { data: 'Hello Parent!' };
        //   event.source.postMessage(response, event.origin);
        // }
        // event.source.postMessage(response, event.origin);
      })
      ```


      #  一次性定时器
      ```javascript
      let attrTimer = false
    const updateAttribute = () => {
      // console.log(state.chartStyle.attribute)
      clearTimeout(attrTimer)
      attrTimer = setTimeout(() => {
        console.log('更新属性' + state.curComponent.id)
      }, 1500)
    }
    ```

你可能感兴趣的:(前端)