【发布时间】:2021-04-02 02:47:12
【问题描述】:
我正在使用 nativescript-vue 开发一个应用程序,我需要显示一些外部图像。
我正在尝试使用 nativescript-photoviewer 插件。
这是我的代码:
<template>
...
<Image :src="image_path" @tap="onImageTap" />
...
</template>
<script>
// Include the module
import { PhotoViewer, PhotoViewerOptions, PaletteType, NYTPhotoItem } from "nativescript-photoviewer";
...
methods: {
onImageTap: function() {
let image1 =
"https://pat-book.es/storage/user_images/allergies/3qwTKMNU2tRqHhJtFRce5S3fNgel9twafrFl9FWj.jpeg";
let image2 =
"https://pat-book.es/storage/user_images/allergies/4MtvyhpyzHIdj993pEj3MoubmRJQWAhGdhotaT6h.jpeg";
let images = [image1, image2];
let photoViewer = new PhotoViewer();
photoViewer.showGallery(images);
}
</script>
这些图像是动态的。
我不使用选项,只要它们是可选的。
这是我得到的错误:
JS: [Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'startIndex' of undefined"
System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onTouch failed
System.err: TypeError: Cannot read property 'startIndex' of undefined
System.err:
System.err: StackTrace:
System.err: PhotoViewer.showGallery(file:///app\photoviewer.android.ts:21:41)
System.err: at onImageTap(file:///app\pages\allergies\AllergiesDetailsPage.vue:173:0)
...
这是错误上升的插件源代码:
public showGallery(imagesArray: Array<string>, options?: PhotoViewerOptions) {
var photosArray = new java.util.ArrayList();
imagesArray.forEach((imgUrl: string) => {
photosArray.add(imgUrl);
});
let startIndex: number = options.startIndex || 0; // Line 21
...
有人设法用 vue 运行这个插件吗?提供的唯一示例是 angular 和 typescript。
【问题讨论】:
标签: vue.js nativescript