NativeScript / NativeScript/plugins

imagepicker with NativeScript Vue is not working

Đang mở
#573 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
TypeScript
Star
206
Fork
123
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
1

Mô tả

Hello,

I'm writing an application in nativescript vue where I need to pick an image on iOS Photo Library.
For that I wanted to use the imagepicker plugin.

Authorization is working and I can select the pictures, but unfortunately as result I got that the uri is undefined.
Here after my code :

<template>
  <Page @loaded="onPageLoaded">
      <ActionBar title="Select Image" />
      <StackLayout>
          <Button text="Select Image" @tap="onSelectImageTap" />
          <Image v-if="selectedImage" :src="selectedImage" stretch="aspectFill" />
      </StackLayout>
  </Page>
</template>
<script>
import * as ImagePicker from 'nativescript-imagepicker';
export default {
  data() {
      return {
          selectedImage: null,
          imagePicker: null // Initialize imagePicker property
      };
  },
  methods: {
      onPageLoaded() {
          this.imagePicker = ImagePicker.create({
              mode: 'single' // or 'multiple'
          });
      },
      async onSelectImageTap() {
          try {
              if (!this.imagePicker) {
                  console.error('ImagePicker is not initialized.');
                  return;
              }
              await this.imagePicker.authorize();
              const selection = await this.imagePicker.present();
              console.log('Selection:', selection.map(item => ({ uri: item.uri })));
              if (selection && selection.length > 0 && selection[0].uri) {
                  this.selectedImage = selection[0].uri;
              } else {
                  console.error('No image selected or URI is undefined.');
              }
          } catch (error) {
              console.error('Error selecting image:', error);
          }
      }
  }
};
</script>

It seems that the same issue is happing also on the demo available under : https://www.npmjs.com/package/@nativescript/imagepicker#demo -> https://stackblitz.com/edit/nativescript-vue3-beta-krjk9k?file=app%2Fcomponents%2FHome.vue,app%2Fapp.css

Can you support me on this issue?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản demo StackBlitz được liên kết trên iOS và kiểm tra app/components/Home.vue; app/app.css có sẵn như một phần của bản demo. Tái hiện thao tác chọn ảnh và so sánh đối tượng lựa chọn được trả về với undefined uri được ghi trong issue. Hoàn tất khi ảnh được chọn cung cấp một URI có thể sử dụng trong ví dụ NativeScript Vue.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
ios, typescript
Lĩnh vực
mobile-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.