未捕获的syntaxerror意外令牌main.js选择器:' page-home',模板: - ionic3

时间:2017-11-13 10:44:29

标签: android ionic-framework ionic3

在Android 6 Marshmallow上,它可以在apk版本中正常运行 但是在"选择器中出错:" Android Lollipop中的代码行

错误:

  

未捕获的SyntaxError:main.js中的意外标记ILLEGAL警告:   "关键"视口适合"不被承认和忽略"

我不知道出了什么问题。

 `HomePage = __decorate([
        Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["m" /* Component */])({
            selector: 'page-home',template:/*ion-inline-start:"D:\2fb\src\pages\home\home.html"*/`\n  \n    \n      Facebook\n    \n  \n\n\n\n  \n    Facebook Login Example\n  \n\n  \n    Log In with Facebook\n  \n\n  \n    \n    \n      \n        {{ userProfile.displayName }}\n      \n      

\n The UID for this new user is {{userProfile.uid}} and the email is {{userProfile.email}}\n

\n \n \n`/*ion-inline-end:"D:\2fb\src\pages\home\home.html"*/ }), __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_2_ionic_angular__["d" /* NavController */], __WEBPACK_IMPORTED_MODULE_1__ionic_native_facebook__["a" /* Facebook */]]) ], HomePage);`

1 个答案:

答案 0 :(得分:0)

在部署到Android 4.4.4时,我使用3.9.2遇到了类似的问题。可能的原因是模板字符串包含`(ASCII 96)不是常见的单引号(ASCII 39)。

我的丑陋修复是使用after prepare脚本替换`with',如下所示:

#!/usr/bin/env node

var fs = require('fs');
var path = require('path');

var rootdir = process.argv[2] + '/../';

function replace_string_in_file(filename, to_replace, replace_with) {
  var data = fs.readFileSync(filename, 'utf8');

  var result = data.replace(new RegExp(to_replace, "g"), replace_with);
  fs.writeFileSync(filename, result, 'utf8');
}

var target = "dev";
if (process.env.TARGET) {
  target = process.env.TARGET;
}

var replaceConfig = {
  "platforms/android/assets/www/build/main.js" : {
    "dev": {
      "/`": "/'",
      "`/": "'/"
    }
  }
};
for (var filename in replaceConfig) {
  var fullFilename = path.join(rootdir, filename);
  if (fs.existsSync(fullFilename)) {
    var replaceTexts = replaceConfig[filename];
    for (var key in replaceTexts[target]) {
      console.log(target + " replacing in file: " + fullFilename + " " + key + " as " + replaceTexts[target][key]);
      replace_string_in_file(fullFilename, key, replaceTexts[target][key]);
    }
  } else {
    console.log("missing: " + fullFilename);
  }
}

它解决了我的问题。希望这会有所帮助。