我必须按照这些步骤来验证我的应用程序,但是我在创建链接到我的文件的路径时遇到了问题。
上面的链接是我得到的说明,我创建了文本文件,并将它放在我的 angular 2 应用程序的资产文件夹中。但是我不知道如何创建路由http://www.example.com/riot.txt以便它引用我的 txt 文档文件。任何人都可以指出我正确的方向吗?我正在使用 Angular 2。
我正在构建一个使用 angular 的电子应用程序。但是,当我尝试使用电子构建器打包应用程序时,出现错误:
Not allowed to load local resource: file:///C:/Users/Eric/AppData/Local/Programs/kaysi/resources/app.asar/dist/index.html
Run Code Online (Sandbox Code Playgroud)
我使用了电子和电子制造商的所有快速启动。但是,我确实添加了 dist/ 以使其与
win.loadURL(url.format({
pathname: path.join(__dirname, 'dist/index.html'),
protocol: 'file:',
slashes: true
}))
Run Code Online (Sandbox Code Playgroud)
如果使用,我的应用程序运行良好,electron .但只有在我运行安装程序后才会发生。
setting.component.ts
import { Component, OnInit } from '@angular/core';
import { ElectronService } from 'ngx-electron';
@Component({
selector: 'app-setting',
templateUrl: './setting.component.html',
styleUrls: ['./setting.component.css']
})
export class SettingComponent implements OnInit {
private primaryServer: string;
private secondaryServer: string;
constructor(
private electron: ElectronService
) { }
ngOnInit() {
this.electron.ipcRenderer.send("asynchronous-message", {get: "settings"})
this.electron.ipcRenderer.on("asynchronous-reply", (event, data) => {
this.primaryServer = data.database.primary;
this.secondaryServer = data.database.secondary;
})
}
}
Run Code Online (Sandbox Code Playgroud)
设置.component.html
<p>{{primaryServer}}</p>
<p>{{secondaryServer}}</p>
Run Code Online (Sandbox Code Playgroud)
我的“primaryServer”和“secondaryServer”值在页面加载时不显示。但是,当我单击输入或随机按钮时,它会显示出来。我如何让它们出现在 init 上?