NervJS/nerv

[bug]IE8下import { Component } from 'nervjs'报错

Opened this issue · 4 comments

现象

import Nerv, { Component } from 'nervjs'

class A extends Component {
...
}

Chrome下运行正常,在IE 8下运行P抛错new TypeError('Super expression must either be null or a function') 例外被抛出未接住

一种解决方法:

import Nerv from 'nervjs'

class A extends Nerv.Component {
...
}

请问是否能从Nerv本身层面解决这个问题?

yuche commented

应该是 babel 设置的问题, 把 class-propertiesspec 打开:

// .babelrc
{
  "plugins": [
    ["transform-class-properties", { "spec": true }]
  ]
}

使用https://github.com/NervJS/nerv-webpack-boilerplate.

"plugins": [
    ["@babel/plugin-proposal-class-properties", { "loose": true }],
  ]

不论loose是否打开 IE8都报错

你的component有super了吗 是component创建失败吧

参考 https://github.com/womendi/nervjs-ie8
package.json中build只写webpack就好,不要加--config *.js