Giter VIP home page Giter VIP logo

Comments (8)

yiludege avatar yiludege commented on June 26, 2024

收到,我来复现一下哈

from wujie.

jawn-ha avatar jawn-ha commented on June 26, 2024

我是通过 script 标签加载 umd 包直接引入的

from wujie.

yiludege avatar yiludege commented on June 26, 2024

定位到是 Zepto.js 引入的问题

from wujie.

jawn-ha avatar jawn-ha commented on June 26, 2024

定位到是 Zepto.js 引入的问题

有什么解决方案吗?

from wujie.

yiludege avatar yiludege commented on June 26, 2024

这个地方能否打个断点,查看一下this、r 之类的变量具体是什么

from wujie.

jawn-ha avatar jawn-ha commented on June 26, 2024

目前看来,this和r好像都是 Window的proxy对象
image

另外,我把clappr.js exclude掉,页面没有报错了,但依旧无法展示。

from wujie.

yiludege avatar yiludege commented on June 26, 2024

已经查明问题:

  • 子应用中 window 是一个 proxy 对象
  • zepto.js 调用 $(window).width() 时会判断传进来的 window 是否是是 window 对象,如果不是的话进一步判断是不是 document 对象
  • 判断方式如下
  function isWindow(obj)     { return obj != null && obj == obj.window }
  function isDocument(obj)   { return obj != null && obj.nodeType == obj.DOCUMENT_NODE }
  • 结果 proxy 对象 isWindow 返回 false(没有代理 window属性),而 isDocument 返回 true(nodeType、DOCUMENT_NODE都为false),程序认为 window 对象是一个 document 对象从而直接读取 document 属性导致出错

from wujie.

yiludege avatar yiludege commented on June 26, 2024

注意到 zepto.js 直接使用 npm install zepto 安装,import $ from 'zepto'使用在 webpack 框架中打包会出现错误,因为webpack 的 chunck 运行时 this 指向为 {},这个问题详见 issue,虽然 pr 已经合入但是仍然没有发版,建议不要使用 zepto.js 这个5年前的包了。

from wujie.

Related Issues (20)

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.