mpvue icon indicating copy to clipboard operation
mpvue copied to clipboard

Cannot read property 'createTextNode' of undefined

Open suiyang1714 opened this issue 6 years ago • 14 comments

_20190123110953 我这边将mpvue开发的微信小程序迁移一版百度小程序,使用百度提供的迁移工具转换以后,出现错误: _20190123111259

suiyang1714 avatar Jan 23 '19 03:01 suiyang1714

这是按照百度转换流程做的,页面组件原封不动的移动

suiyang1714 avatar Jan 23 '19 03:01 suiyang1714

这里非mpvue问题,出问题的地方在 babel的core-js,这个包里面使用有一个有一个判断优先级调整一下就好 原core-js内异常代码:

// Node.js
  if (isNode) {
    notify = function () {
      process.nextTick(flush);
    };
  // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
  } else if (Observer && !(global.navigator && global.navigator.standalone)) {
    var toggle = true;
    var node = document.createTextNode('');
    new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
    notify = function () {
      node.data = toggle = !toggle;
    };
  // environments with maybe non-completely correct, but existent Promise
  } else if (Promise && Promise.resolve) {
    // Promise.resolve without an argument throws an error in LG WebOS 2
    var promise = Promise.resolve(undefined);
    notify = function () {
      promise.then(flush);
    };
  // for other environments - macrotask based on:
  // - setImmediate
  // - MessageChannel
  // - window.postMessag
  // - onreadystatechange
  // - setTimeout
  } else {
    notify = function () {
      // strange IE + webpack dev server bug - use .call(global)
      macrotask.call(global, flush);
    };
  }

新core-js内代码:

if (isNode) {
    notify = function () {
      process.nextTick(flush);
    };
  // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
  } else if (Promise && Promise.resolve) {
    // Promise.resolve without an argument throws an error in LG WebOS 2
    var promise = Promise.resolve(undefined);
    notify = function () {
      promise.then(flush);
    };
  // for other environments - macrotask based on:
  // - setImmediate
  // - MessageChannel
  // - window.postMessag
  // - onreadystatechange
  // - setTimeout
  } else if (Observer && !(global.navigator && global.navigator.standalone)) {
    var toggle = true;
    var node = document.createTextNode('');
    new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
    notify = function () {
      node.data = toggle = !toggle;
    };
    // environments with maybe non-completely correct, but existent Promise
  } else {
    notify = function () {
      // strange IE + webpack dev server bug - use .call(global)
      macrotask.call(global, flush);
    };
  }

ghost avatar Mar 06 '19 09:03 ghost

当前的版本在安卓下没有问题

在真机iphone下面会出错,且只能在百度小程序开发工具中的web预览中才能找到这个错误。

楼上正解决

目前为了解决iphone真机的问题,只能每次打包后手动替换这段代码

找了2天的bug

终于找到解决问题的方案了

caysnuts avatar Mar 16 '19 08:03 caysnuts

怎么修改node_modules里面的包代码使每次修改刷新的时候能够成功生效

YooCool avatar Apr 03 '19 03:04 YooCool

怎么修改node_modules里面的包代码使每次修改刷新的时候能够成功生效 可以试一下 node_modules/core-js/library/modules/_microtask.js

yuconora avatar Apr 08 '19 05:04 yuconora

怎么修改node_modules里面的包代码使每次修改刷新的时候能够成功生效 可以试一下 node_modules/core-js/library/modules/_microtask.js

谢谢您

YooCool avatar Apr 08 '19 06:04 YooCool

改了 还是报这个错

cdd111 avatar May 29 '19 03:05 cdd111

改了 还是报这个错

你改的哪里的呢

YooCool avatar May 29 '19 05:05 YooCool

改了 还是报这个错

你改的哪里的呢 node_modules/core-js/client/core.js 里的这个代码

cdd111 avatar May 29 '19 06:05 cdd111

改了 还是报这个错

你改的哪里的呢 node_modules/core-js/client/core.js 里的这个代码

node_modules/core-js/library/modules/_microtask.js改这个试试

YooCool avatar May 29 '19 06:05 YooCool

请问用了promise 之后还是会报很多警告 image

myhuangqiang avatar May 29 '19 06:05 myhuangqiang

改了 还是报这个错

你改的哪里的呢 node_modules/core-js/client/core.js 里的这个代码

node_modules/core-js/library/modules/_microtask.js改这个试试

谢谢

cdd111 avatar May 29 '19 08:05 cdd111

可以利用webpack alias ,换成自己目录下的暂时用着 './_microtask$': resolve('build/hack/microtask.js')

adams549659584 avatar Aug 15 '19 02:08 adams549659584

请问用了promise 之后还是会报很多警告 image

我也遇到了。

wanghanwanghan avatar Nov 22 '19 08:11 wanghanwanghan