在 Android 6 Marshmallow 上,apk 构建时它工作正常 但在 Android Lollipop 中的“选择器:”代码行处出错
错误:
Uncaught SyntaxError: Unexpected token ILLEGAL in main.js warning : "The key "viewport-fit" is not recognized and ignored"
不知道怎么回事。
`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);`
最佳答案
当部署到 Android 4.4.4 时,我在使用 3.9.2 时遇到了类似的问题。可能的原因是用`(ASCII 96) 括起来的模板字符串不是常见的单引号(ASCII 39)。
我的丑陋修复是通过使用 after prepare 脚本将 ` 替换为 ' ,如下所示:
#!/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);
}
}
它解决了我的问题。希望这会有所帮助。
关于android - 未捕获的语法错误意外标记 main.js 选择器 : 'page-home' , 模板:- ionic3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47262470/