Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

结合babelify使用的时候,runtime.js会报错 #112

Open
zhuowenli opened this issue Feb 18, 2016 · 4 comments
Open

结合babelify使用的时候,runtime.js会报错 #112

zhuowenli opened this issue Feb 18, 2016 · 4 comments

Comments

@zhuowenli
Copy link

结合 babelify 使用的时候,babelify 会重新编译代码,导致 runtime.jsthis指向undefined:

var String = this.String;

建议改成:

var String = window.String;
@aui
Copy link
Owner

aui commented Feb 18, 2016

你是绿箭?这个项目两年没有维护了,不建议使用在正式项目中…

@aui
Copy link
Owner

aui commented Feb 18, 2016

模板可以考虑采用基于 webpack 的方案

@stuxt
Copy link

stuxt commented Sep 7, 2016

@aui 这个项目目前么有人维护了吗?

@malun666
Copy link

malun666 commented Apr 21, 2018

暂时可以用gulpgulp-replace插件,把这个this.String换成window.String

var String = this.String;
// 修改为:
var String = window.String;

gulp-replace插件

gulp.task('tpl', function() {
  gulp
    .src('src/template/**/*.html')
    .pipe(
      tmodjs({
        templateBase: 'src/template',
        runtime: 'htmlTpl.js',
        compress: false
      })
    )
    // 主要是this  →  window
    .pipe(replace('var String = this.String;', 'var String = window.String;'))
    .pipe(gulp.dest('src/js'));
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants