【发布时间】:2023-04-04 08:35:02
【问题描述】:
我一直在做一个需要在应用内打开网站的项目。 所以,我将 Cordova InAppBrowse 用于离子 3。 问题是,我收到错误显示解析错误。
在 index.html 上
<div style="text-align: center;">
<button ion-button type="button" (click)="open('https://coins4ar.com/{{coinsGroup.symbol}}/')">More Info
</button>
</div>
在 index.ts 上
import { InAppBrowser } from '@ionic-native/in-app-browser';
@Component({
selector: 'page-index',
templateUrl: 'index.html'
})
export class IndexPage {
constructor(public navCtrl: NavController, public navParams: NavParams, private iab: InAppBrowser,
private data: DataProvider, public http: HttpClient) {
}
coinsGroup = [];
ionViewDidLoad() {
this.coinsGroup = this.navParams.data;
}
open(url:string) {
let browser = this.iab.create(url,'_blank', 'location=yes');
browser.show();
}
}
我遇到了错误
VM66652 vendor.js:100970 Uncaught Error: Template parse errors:
Parser Error: Got interpolation ({{}}) where expression was expected at column 27 in [open('https://coins4ar.com/{{coinsGroup.symbol}}/')] in ng:///AppModule/IndexPage.html@190:39 ("
-->
<button ion-button type="button" [ERROR ->](click)="open('https://coins4ar.com/{{coinsGroup.symbol}}/')">More Info</button>
</div>
"): ng:///AppModule/IndexPage.html@190:39
at syntaxError (VM64228 vendor.js:100970)
at TemplateParser.parse (VM64228 vendor.js:125153)
at JitCompiler._parseTemplate (VM64228 vendor.js:135106)
at JitCompiler._compileTemplate (VM64228 vendor.js:135081)
at VM64228 vendor.js:134982
at Set.forEach (<anonymous>)
at JitCompiler._compileComponents (VM64228 vendor.js:134982)
at VM64228 vendor.js:134852
at Object.then (VM64228 vendor.js:100959)
at JitCompiler._compileModuleAndComponents (VM64228 vendor.js:134851)
使用 Anchor Tag 时可以正常工作,但会在应用程序之外启动网站。
【问题讨论】:
标签: ionic3 inappbrowser