要动态设置iframe的src属性为pdf,可以使用以下方法:
export class YourComponent {
pdfSrc: string = '';
// 其他代码...
}
export class YourComponent {
pdfSrc: string = '';
constructor() {
// 设置pdfSrc为你的pdf URL
this.pdfSrc = 'https://example.com/your-pdf.pdf';
}
// 其他代码...
}
这样,当组件初始化时,你的pdf文件将会自动加载到iframe中。你也可以根据需要在代码中的任何位置动态更新pdfSrc变量的值,以加载不同的pdf文件。