NativeScript / NativeScript/plugins
imagepicker with NativeScript Vue is not working
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- TypeScript
- Estrellas
- 206
- Forks
- 123
- Merge medio
- 2 d 1 h
- PR fusionados (30 d)
- 1
Descripción
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?
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza ejecutando la demo enlazada de StackBlitz en iOS e inspecciona app/components/Home.vue; app/app.css está disponible como parte de la demo. Reproduce la selección de imágenes y compara el objeto de selección devuelto con la undefined uri registrada en el issue. Se considera completado cuando la imagen seleccionada expone una URI utilizable en el ejemplo de NativeScript Vue.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- ios, typescript
- Área
- mobile-dev
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100