Mui*_*rik 8 javascript mailto typescript angular
我正在尝试在我的Angular 2应用程序中设置一个功能,该功能将使用用户的默认电子邮件客户端发送一封电子邮件,其中包含一些预先填充的信息:
sendEmail() {
this.title = document.title;
this.title = this.title.replace("&", "-");
window.location = "mailto:?body=" + this.title + " - " + window.location + "&subject=I thought this link might interest you.";
}
Run Code Online (Sandbox Code Playgroud)
但我遇到了一个问题,我收到了一个错误:
无法分配到"位置",因为它是常量或只读属性.webpack:编译失败.
我到目前为止看到的例子都描述了这样做,使用"window.location",那么我该如何解决这个问题呢?
joh*_*667 15
你错过了 href
window.location.href = ....
Run Code Online (Sandbox Code Playgroud)
您也可以通过为Angular Router提供一个静态URL 来执行此操作:
this.router.navigateByUrl('url')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3876 次 |
| 最近记录: |