将应用程序中存储的本地pdf读取到Nativescript中的pdf查看器

将应用程序中存储的本地pdf读取到Nativescript中的pdf查看器,nativescript,Nativescript,我正在使用nativescript pdf viewer()以联机和本地存储的方式查看pdf 我在github和文档中尝试了几个答案,但没有一个主题是有效的。我有如下路径的输出: const currentAppFolder = fileSystemModule.knownFolders.currentApp() const filePath = fileSystemModule.path.join(currentAppFolder.path, "assets", "test.pdf") thi

我正在使用nativescript pdf viewer()以联机和本地存储的方式查看pdf

我在github和文档中尝试了几个答案,但没有一个主题是有效的。我有如下路径的输出:

const currentAppFolder = fileSystemModule.knownFolders.currentApp()
const filePath = fileSystemModule.path.join(currentAppFolder.path, "assets", "test.pdf")
this.pdfPath = filePath 
可以获取路径,但当绑定到PdfView元素的src时,它不返回任何内容(无显示)


我正在将Nativescript Vue用于此项目。

问题完全与我的网页配置有关。在这个片段中

//webpack.config.js

 // Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin([
 { from: "**/*", context: "assets" },
 ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
事实证明,您在根路径
/app/assets/pdf
(以及该资产文件夹中的其他文件)中放置的内容将反映在本地平台文件
platforms/android/app/src/main/assets/app/{资产中的文件/文件夹}

因此,要使用Nativescript的文件系统调用它

 const currentAppFolder = fs.knownFolders.currentApp()
 const filePath = fs.path.join(currentAppFolder.path, 'pdf', 'eq.pdf')
 //console.log('PDF', fs.File.exists(filePath))
 this.pdfPath = filePath
我创建了一个名为Nitibo的nativescript vue typescript模板。
请访问

查看该问题与我的网页配置有关。在这个片段中

//webpack.config.js

 // Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin([
 { from: "**/*", context: "assets" },
 ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
事实证明,您在根路径
/app/assets/pdf
(以及该资产文件夹中的其他文件)中放置的内容将反映在本地平台文件
platforms/android/app/src/main/assets/app/{资产中的文件/文件夹}

因此,要使用Nativescript的文件系统调用它

 const currentAppFolder = fs.knownFolders.currentApp()
 const filePath = fs.path.join(currentAppFolder.path, 'pdf', 'eq.pdf')
 //console.log('PDF', fs.File.exists(filePath))
 this.pdfPath = filePath
我创建了一个名为Nitibo的nativescript vue typescript模板。

上查看是否确定文件是否存在,请尝试
fileSystemModule.file.exists(path)
,如果文件存在,它将返回true。我发现它变为false,因此无法找到路径。我的目标是我放置一个pdf,所以我将它放置在项目的根目录app/assets/pdf/eq.pdf中,但找不到它,即使app/assets/pdf变为false,但app/assets为true。。这个项目到底在哪里?我可以在任何nativescript讨论中找到它。我正在使用webpack,可能它没有复制要生成的文件?是否确定该文件是否存在,请尝试
fileSystemModule.file.exists(path)
,如果文件存在,则返回true。我发现它变为false,因此无法找到路径。我的目标是我放置一个pdf,所以我将它放置在项目的根目录app/assets/pdf/eq.pdf中,但找不到它,即使app/assets/pdf变为false,但app/assets为true。。这个项目到底在哪里?我可以在任何nativescript讨论中找到它。我正在使用webpack,可能它没有复制要生成的文件?